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 57207 Details for
Bug 161932
Use of internal packages in wsdm tooling tech preview
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 for removing QName and XMLDuration internal apis
patch.txt (text/plain), 784.29 KB, created by
Saurabh Dravid
on 2007-01-20 08:37:01 EST
(
hide
)
Description:
Patch for removing QName and XMLDuration internal apis
Filename:
MIME Type:
Creator:
Saurabh Dravid
Created:
2007-01-20 08:37:01 EST
Size:
784.29 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.tptp.wsdm.tooling.editor.capability >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/operation/internal/RemoveExceptionCommand.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.editor.capability/src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/operation/internal/RemoveExceptionCommand.java,v >retrieving revision 1.4 >diff -u -r1.4 RemoveExceptionCommand.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/operation/internal/RemoveExceptionCommand.java 9 Jan 2007 19:51:44 -0000 1.4 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/operation/internal/RemoveExceptionCommand.java 20 Jan 2007 13:33:30 -0000 >@@ -45,9 +45,9 @@ > public RemoveExceptionCommand(CapabilityDomain capabilityDomain, > Operation operation, Fault fault) > { >- _capabilityDomain = capabilityDomain; >- _operation = operation; >- _fault = fault; >+ _capabilityDomain = capabilityDomain; >+ _operation = operation; >+ _fault = fault; > } > > /** >@@ -55,28 +55,28 @@ > */ > public void execute() > { >- Definition definition = _capabilityDomain.getDefinition(); >- Message faultMessage = _fault.getEMessage(); >- // If the fault message falls in the same capability definition >- // Then remove the fault message and xsd decalaration element for that >- if(faultMessage.getEnclosingDefinition().equals(definition)) >- { >- List parts = faultMessage.getEParts(); >- if(parts!=null && parts.size()!=0) >- { >- Part part = (Part) parts.get(0); >- XSDElementDeclaration faultElement = part.getElementDeclaration(); >- // If faultElement defined in the same wsdl file >- // Then remove the faultElement >- XSDSchema faultSchema = WsdlUtils.getSchema(definition, faultElement.getTargetNamespace()); >- if(faultSchema!=null) >- faultSchema.getContents().remove(faultElement); >- faultMessage.getEParts().remove(part); >- } >- _fault.setEMessage(null); >- definition.getEMessages().remove(faultMessage); >- } >- _operation.getEFaults().remove(_fault); >+ Definition definition = _capabilityDomain.getCapability().getDefinition(); >+ Message faultMessage = _fault.getEMessage(); >+ // If the fault message falls in the same capability definition >+ // Then remove the fault message and xsd decalaration element for that >+ if(faultMessage.getEnclosingDefinition().equals(definition)) >+ { >+ List parts = faultMessage.getEParts(); >+ if(parts!=null && parts.size()!=0) >+ { >+ Part part = (Part) parts.get(0); >+ XSDElementDeclaration faultElement = part.getElementDeclaration(); >+ // If faultElement defined in the same wsdl file >+ // Then remove the faultElement >+ XSDSchema faultSchema = WsdlUtils.getSchema(definition, faultElement.getTargetNamespace()); >+ if(faultSchema!=null) >+ faultSchema.getContents().remove(faultElement); >+ faultMessage.getEParts().remove(part); >+ } >+ _fault.setEMessage(null); >+ definition.getEMessages().remove(faultMessage); >+ } >+ _operation.getEFaults().remove(_fault); > } > > } >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/operation/internal/AddOperationCommand.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.editor.capability/src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/operation/internal/AddOperationCommand.java,v >retrieving revision 1.6 >diff -u -r1.6 AddOperationCommand.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/operation/internal/AddOperationCommand.java 9 Jan 2007 19:51:44 -0000 1.6 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/operation/internal/AddOperationCommand.java 20 Jan 2007 13:33:30 -0000 >@@ -35,8 +35,6 @@ > public class AddOperationCommand > { > >- private Definition _definition; >- > private Operation _newOperation; > > private Capability _capability; >@@ -47,9 +45,8 @@ > public AddOperationCommand(CapabilityDomain capabilityDomain, > Operation newOperation) > { >- _definition = capabilityDomain.getDefinition(); >- _capability = capabilityDomain.getCapability(); >- _newOperation = newOperation; >+ _capability = capabilityDomain.getCapability(); >+ _newOperation = newOperation; > } > > /** >@@ -59,69 +56,71 @@ > */ > public void execute() > { >- >- // Remember Old Refs >- List faultMessages = new ArrayList(); >- Message inputMessage = _newOperation.getEInput().getEMessage(); >- Message outputMessage = _newOperation.getEOutput().getEMessage(); >- >- for (int i = 0; i < _newOperation.getEFaults().size(); i++) >- { >- Fault fault = (Fault) _newOperation.getEFaults().get(i); >- faultMessages.add(fault.getEMessage()); >- } >- >- PortType portType = WsdlUtils.getPortType(_definition); >- _newOperation.setEnclosingDefinition(portType.getEnclosingDefinition()); >- portType.addOperation(_newOperation); >- >- // Add Old Refs >- _newOperation.getEInput().setEMessage(inputMessage); >- _newOperation.getEOutput().setEMessage(outputMessage); >- >- for (int i = 0; i < faultMessages.size(); i++) >- { >- Fault fault = (Fault) _newOperation.getEFaults().get(i); >- Message faultMsg = (Message) faultMessages.get(i); >- fault.setEMessage(faultMsg); >- } >+ Definition _definition = _capability.getDefinition(); >+ // Remember Old Refs >+ List faultMessages = new ArrayList(); >+ Message inputMessage = _newOperation.getEInput().getEMessage(); >+ Message outputMessage = _newOperation.getEOutput().getEMessage(); >+ >+ for (int i = 0; i < _newOperation.getEFaults().size(); i++) >+ { >+ Fault fault = (Fault) _newOperation.getEFaults().get(i); >+ faultMessages.add(fault.getEMessage()); >+ } >+ >+ PortType portType = WsdlUtils.getPortType(_definition); >+ _newOperation.setEnclosingDefinition(portType.getEnclosingDefinition()); >+ portType.addOperation(_newOperation); > >- addAction(_newOperation.getEInput()); >- addAction(_newOperation.getEOutput()); >+ // Add Old Refs >+ _newOperation.getEInput().setEMessage(inputMessage); >+ _newOperation.getEOutput().setEMessage(outputMessage); > >- // Add this operation to capability >- _capability.getOperations().add(_newOperation); >+ for (int i = 0; i < faultMessages.size(); i++) >+ { >+ Fault fault = (Fault) _newOperation.getEFaults().get(i); >+ Message faultMsg = (Message) faultMessages.get(i); >+ fault.setEMessage(faultMsg); >+ } >+ >+ addAction(_newOperation.getEInput()); >+ addAction(_newOperation.getEOutput()); >+ >+ // Add this operation to capability >+ _capability.getOperations().add(_newOperation); > } > > private void addAction(Input input) > { >- String action = getAction(input.getEMessage()); >- Message inputMessage = input.getEMessage(); >- input.getElement().setAttributeNS(WsdmConstants.WSA_URI, WsdmConstants.WSA_ACTION_NAME, action); >- input.setEMessage(inputMessage); >- _definition.addNamespace(WsdmConstants.WSA_PREFIX, WsdmConstants.WSA_URI); >+ Definition _definition = _capability.getDefinition(); >+ String action = getAction(input.getEMessage()); >+ Message inputMessage = input.getEMessage(); >+ input.getElement().setAttributeNS(WsdmConstants.WSA_URI, WsdmConstants.WSA_ACTION_NAME, action); >+ input.setEMessage(inputMessage); >+ _definition.addNamespace(WsdmConstants.WSA_PREFIX, WsdmConstants.WSA_URI); > } > > private void addAction(Output output) > { >- String action = getAction(output.getEMessage()); >- Message outputMessage = output.getEMessage(); >- output.getElement().setAttributeNS(WsdmConstants.WSA_URI, WsdmConstants.WSA_ACTION_NAME, action); >- output.setEMessage(outputMessage); >- _definition.addNamespace(WsdmConstants.WSA_PREFIX, WsdmConstants.WSA_URI); >+ Definition _definition = _capability.getDefinition(); >+ String action = getAction(output.getEMessage()); >+ Message outputMessage = output.getEMessage(); >+ output.getElement().setAttributeNS(WsdmConstants.WSA_URI, WsdmConstants.WSA_ACTION_NAME, action); >+ output.setEMessage(outputMessage); >+ _definition.addNamespace(WsdmConstants.WSA_PREFIX, WsdmConstants.WSA_URI); > } > > private String getAction(Message message) > { >- String uri = message.getQName().getNamespaceURI(); >- String name = message.getQName().getLocalPart(); >- name = name.substring(0, 1).toUpperCase() + name.substring(1); >- return uri + "/" + name; >+ String uri = message.getQName().getNamespaceURI(); >+ String name = message.getQName().getLocalPart(); >+ name = name.substring(0, 1).toUpperCase() + name.substring(1); >+ return uri + "/" + name; > } > > public Operation getOperation() > { >- return _newOperation; >+ return _newOperation; > } > > } >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/operation/internal/RemoveOperationCommand.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.editor.capability/src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/operation/internal/RemoveOperationCommand.java,v >retrieving revision 1.4 >diff -u -r1.4 RemoveOperationCommand.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/operation/internal/RemoveOperationCommand.java 9 Jan 2007 19:51:44 -0000 1.4 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/operation/internal/RemoveOperationCommand.java 20 Jan 2007 13:33:30 -0000 >@@ -35,8 +35,6 @@ > public class RemoveOperationCommand > { > >- private Definition _definition; >- > private Operation _operation; > > private Capability _capability; >@@ -49,10 +47,9 @@ > public RemoveOperationCommand(CapabilityDomain capabilityDomain, > Operation operation) > { >- _capabilityDomain = capabilityDomain; >- _definition = capabilityDomain.getDefinition(); >- _capability = capabilityDomain.getCapability(); >- _operation = operation; >+ _capabilityDomain = capabilityDomain; >+ _capability = capabilityDomain.getCapability(); >+ _operation = operation; > } > > /** >@@ -62,68 +59,71 @@ > */ > public void execute() > { >- PortType portType = WsdlUtils.getPortType(_definition); >- removeMessages(); >- removeFaults(); >- portType.getEOperations().remove(_operation); >- >- // Remove from the capability >- _capability.getOperations().remove(_operation); >+ Definition _definition = _capability.getDefinition(); >+ PortType portType = WsdlUtils.getPortType(_definition); >+ removeMessages(); >+ removeFaults(); >+ portType.getEOperations().remove(_operation); >+ >+ // Remove from the capability >+ _capability.getOperations().remove(_operation); > } > > private void removeMessages() > { >- Message inpMsg = _operation.getEInput().getEMessage(); >- >- // If the input message falls in the same capability definition >- // Then remove the input message and xsd decalaration element for that >- if(inpMsg.getEnclosingDefinition().equals(_definition)) >- { >- removeElementDeclaration(inpMsg.getEParts()); >- _definition.getEMessages().remove(inpMsg); >- } >- >- // If the output message falls in the same capability definition >- // Then remove the output message and xsd decalaration element for that >- Message outMsg = _operation.getEOutput().getEMessage(); >- if(outMsg.getEnclosingDefinition().equals(_definition)) >- { >- removeElementDeclaration(outMsg.getEParts()); >- _definition.getEMessages().remove(outMsg); >- } >+ Message inpMsg = _operation.getEInput().getEMessage(); >+ >+ // If the input message falls in the same capability definition >+ // Then remove the input message and xsd decalaration element for that >+ Definition _definition = _capability.getDefinition(); >+ if(inpMsg.getEnclosingDefinition().equals(_definition)) >+ { >+ removeElementDeclaration(inpMsg.getEParts()); >+ _definition.getEMessages().remove(inpMsg); >+ } >+ >+ // If the output message falls in the same capability definition >+ // Then remove the output message and xsd decalaration element for that >+ Message outMsg = _operation.getEOutput().getEMessage(); >+ if(outMsg.getEnclosingDefinition().equals(_definition)) >+ { >+ removeElementDeclaration(outMsg.getEParts()); >+ _definition.getEMessages().remove(outMsg); >+ } > } > > private void removeElementDeclaration(List partList) > { >- if(partList == null) >- return; >- >- for (int i = 0; i < partList.size(); i++) >- { >- Part part = (Part) partList.get(i); >- XSDElementDeclaration element = part.getElementDeclaration(); >- if(element!=null) >- { >- // If Element defined in the same wsdl file >- // Then remove the Element >- XSDSchema elementSchema = WsdlUtils.getSchema(_definition, element.getTargetNamespace()); >- if(elementSchema!=null) >- element.getSchema().getContents().remove(element); >- } >- } >+ Definition _definition = _capability.getDefinition(); >+ if(partList == null) >+ return; >+ >+ for (int i = 0; i < partList.size(); i++) >+ { >+ Part part = (Part) partList.get(i); >+ XSDElementDeclaration element = part.getElementDeclaration(); >+ if(element!=null) >+ { >+ // If Element defined in the same wsdl file >+ // Then remove the Element >+ XSDSchema elementSchema = WsdlUtils.getSchema(_definition, element.getTargetNamespace()); >+ if(elementSchema!=null) >+ element.getSchema().getContents().remove(element); >+ } >+ } > } > > private void removeFaults() > { >- List faults = _operation.getEFaults(); >- if(faults == null) >- return; >- for (int i = 0; i < faults.size(); i++) >- { >- Fault fault = (Fault) faults.get(i); >- RemoveExceptionCommand command = new RemoveExceptionCommand(_capabilityDomain, _operation, fault); >- command.execute(); >- } >+ List faults = _operation.getEFaults(); >+ if(faults == null) >+ return; >+ for (int i = 0; i < faults.size(); i++) >+ { >+ Fault fault = (Fault) faults.get(i); >+ RemoveExceptionCommand command = new RemoveExceptionCommand(_capabilityDomain, _operation, fault); >+ command.execute(); >+ } > } > > } >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/operation/internal/AddExceptionCommand.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.editor.capability/src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/operation/internal/AddExceptionCommand.java,v >retrieving revision 1.3 >diff -u -r1.3 AddExceptionCommand.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/operation/internal/AddExceptionCommand.java 9 Jan 2007 19:51:44 -0000 1.3 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/operation/internal/AddExceptionCommand.java 20 Jan 2007 13:33:30 -0000 >@@ -35,9 +35,9 @@ > */ > public AddExceptionCommand(CapabilityDomain capabilityDomain, Operation operation, Fault fault) > { >- _capabilityDomain = capabilityDomain; >- _operation = operation; >- _fault = fault; >+ _capabilityDomain = capabilityDomain; >+ _operation = operation; >+ _fault = fault; > } > > /** >@@ -46,11 +46,9 @@ > */ > public void execute() > { >- Definition definition = _capabilityDomain.getDefinition(); >- >- definition.addMessage(_fault.getEMessage()); >- >- _operation.addFault(_fault); >+ Definition definition = _capabilityDomain.getCapability().getDefinition(); >+ definition.addMessage(_fault.getEMessage()); >+ _operation.addFault(_fault); > } > > } >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/internal/CapabilityStorage.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.editor.capability/src/org/eclipse/tptp/wsdm/tooling/editor/capability/internal/CapabilityStorage.java,v >retrieving revision 1.2 >diff -u -r1.2 CapabilityStorage.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/capability/internal/CapabilityStorage.java 9 Jan 2007 19:51:44 -0000 1.2 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/internal/CapabilityStorage.java 20 Jan 2007 13:33:34 -0000 >@@ -15,12 +15,12 @@ > import java.io.InputStream; > import java.io.StringBufferInputStream; > >-import org.apache.muse.util.xml.XmlUtils; > 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.util.internal.CapUtils; > import org.eclipse.tptp.wsdm.tooling.util.internal.WsdlUtils; > import org.eclipse.wst.wsdl.Definition; > >@@ -40,7 +40,7 @@ > } > > public InputStream getContents() throws CoreException { >- String str = XmlUtils.toString(_definition.getElement()); >+ String str = CapUtils.documentToString(_definition.getElement().getOwnerDocument()); > StringBufferInputStream stream = new StringBufferInputStream(str); > return stream; > } >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/internal/CapabilityEditor.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.editor.capability/src/org/eclipse/tptp/wsdm/tooling/editor/capability/internal/CapabilityEditor.java,v >retrieving revision 1.8 >diff -u -r1.8 CapabilityEditor.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/capability/internal/CapabilityEditor.java 9 Jan 2007 19:51:44 -0000 1.8 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/internal/CapabilityEditor.java 20 Jan 2007 13:33:34 -0000 >@@ -17,7 +17,6 @@ > import java.io.IOException; > import java.util.List; > >-import org.apache.muse.util.xml.XmlUtils; > import org.eclipse.core.resources.IFile; > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IProgressMonitor; >@@ -28,12 +27,13 @@ > import org.eclipse.tptp.wsdm.tooling.editor.capability.pages.source.internal.WsdlSourcePage; > import org.eclipse.tptp.wsdm.tooling.editor.capability.pages.source.internal.XsdSourcePage; > import org.eclipse.tptp.wsdm.tooling.editor.capability.pages.topic.internal.TopicPage; >+import org.eclipse.tptp.wsdm.tooling.editor.capability.util.internal.MetaDataUtils; > import org.eclipse.tptp.wsdm.tooling.editor.ui.internal.ISourcePage; > import org.eclipse.tptp.wsdm.tooling.editor.ui.internal.IUIPage; >+import org.eclipse.tptp.wsdm.tooling.model.capabilities.impl.MetadataDescriptor; > import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.internal.Messages; > import org.eclipse.tptp.wsdm.tooling.util.internal.CapUtils; > import org.eclipse.tptp.wsdm.tooling.util.internal.EclipseUtils; >-import org.eclipse.tptp.wsdm.tooling.util.internal.PropertyMetaDataDescriptor; > import org.eclipse.tptp.wsdm.tooling.util.internal.WsdlUtils; > import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmConstants; > import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmToolingLog; >@@ -74,14 +74,14 @@ > */ > IUIPage createOperationPage() > { >- IUIPage operationPage = new OperationPage(getContainer(), this, >- Messages.OPERATION); >- operationPage.create(); >- _operationPageIndex = addPage(operationPage.getForm()); >- setPageText(_operationPageIndex, Messages.OPERATIONS); >- addPropertyListener(operationPage); >- _pages.add(operationPage); >- return operationPage; >+ IUIPage operationPage = new OperationPage(getContainer(), this, >+ Messages.OPERATION); >+ operationPage.create(); >+ _operationPageIndex = addPage(operationPage.getForm()); >+ setPageText(_operationPageIndex, Messages.OPERATIONS); >+ addPropertyListener(operationPage); >+ _pages.add(operationPage); >+ return operationPage; > } > > /** >@@ -89,14 +89,14 @@ > */ > IUIPage createOverviewPage() > { >- IUIPage overviewPage = new OverviewPage(getContainer(), this, >- Messages.OVERVIEW); >- overviewPage.create(); >- _overviewPageIndex = addPage(overviewPage.getForm()); >- setPageText(_overviewPageIndex, Messages.OVERVIEW); >- addPropertyListener(overviewPage); >- _pages.add(overviewPage); >- return overviewPage; >+ IUIPage overviewPage = new OverviewPage(getContainer(), this, >+ Messages.OVERVIEW); >+ overviewPage.create(); >+ _overviewPageIndex = addPage(overviewPage.getForm()); >+ setPageText(_overviewPageIndex, Messages.OVERVIEW); >+ addPropertyListener(overviewPage); >+ _pages.add(overviewPage); >+ return overviewPage; > } > > /** >@@ -104,14 +104,14 @@ > */ > IUIPage createPropertyPage() > { >- IUIPage propertyPage = new PropertyPage(getContainer(), this, >- Messages.PROPERTY); >- propertyPage.create(); >- _propertyPageIndex = addPage(propertyPage.getForm()); >- setPageText(_propertyPageIndex, Messages.PROPERTIES); >- addPropertyListener(propertyPage); >- _pages.add(propertyPage); >- return propertyPage; >+ IUIPage propertyPage = new PropertyPage(getContainer(), this, >+ Messages.PROPERTY); >+ propertyPage.create(); >+ _propertyPageIndex = addPage(propertyPage.getForm()); >+ setPageText(_propertyPageIndex, Messages.PROPERTIES); >+ addPropertyListener(propertyPage); >+ _pages.add(propertyPage); >+ return propertyPage; > } > > /** >@@ -119,13 +119,13 @@ > */ > IUIPage createTopicPage() > { >- IUIPage topicPage = new TopicPage(getContainer(), this, Messages.TOPIC); >- topicPage.create(); >- _topicPageIndex = addPage(topicPage.getForm()); >- setPageText(_topicPageIndex, Messages.TOPICS); >- addPropertyListener(topicPage); >- _pages.add(topicPage); >- return topicPage; >+ IUIPage topicPage = new TopicPage(getContainer(), this, Messages.TOPIC); >+ topicPage.create(); >+ _topicPageIndex = addPage(topicPage.getForm()); >+ setPageText(_topicPageIndex, Messages.TOPICS); >+ addPropertyListener(topicPage); >+ _pages.add(topicPage); >+ return topicPage; > } > > /** >@@ -133,12 +133,12 @@ > */ > ISourcePage createRMDSourcePage() > { >- ISourcePage rmdSourcePage = new RmdSourcePage(getContainer(), this); >- rmdSourcePage.create(); >- _rmdSourcePageIndex = addPage(rmdSourcePage.getControl()); >- setPageText(_rmdSourcePageIndex, Messages.RMD_SOURCE); >- _pages.add(rmdSourcePage); >- return rmdSourcePage; >+ ISourcePage rmdSourcePage = new RmdSourcePage(getContainer(), this); >+ rmdSourcePage.create(); >+ _rmdSourcePageIndex = addPage(rmdSourcePage.getControl()); >+ setPageText(_rmdSourcePageIndex, Messages.RMD_SOURCE); >+ _pages.add(rmdSourcePage); >+ return rmdSourcePage; > } > > /** >@@ -146,12 +146,12 @@ > */ > ISourcePage createWSDLSourcePage() > { >- ISourcePage sourcePage = new WsdlSourcePage(getContainer(), this); >- sourcePage.create(); >- _wsdlSourcePageIndex = addPage(sourcePage.getControl()); >- setPageText(_wsdlSourcePageIndex, Messages.WSDL_SOURCE); >- _pages.add(sourcePage); >- return sourcePage; >+ ISourcePage sourcePage = new WsdlSourcePage(getContainer(), this); >+ sourcePage.create(); >+ _wsdlSourcePageIndex = addPage(sourcePage.getControl()); >+ setPageText(_wsdlSourcePageIndex, Messages.WSDL_SOURCE); >+ _pages.add(sourcePage); >+ return sourcePage; > } > > /** >@@ -159,12 +159,12 @@ > */ > ISourcePage createXSDSourcePage() > { >- ISourcePage sourcePage = new XsdSourcePage(getContainer(), this); >- sourcePage.create(); >- _xsdSourcePageIndex = addPage(sourcePage.getControl()); >- setPageText(_xsdSourcePageIndex, Messages.XSD_SOURCE); >- _pages.add(sourcePage); >- return sourcePage; >+ ISourcePage sourcePage = new XsdSourcePage(getContainer(), this); >+ sourcePage.create(); >+ _xsdSourcePageIndex = addPage(sourcePage.getControl()); >+ setPageText(_xsdSourcePageIndex, Messages.XSD_SOURCE); >+ _pages.add(sourcePage); >+ return sourcePage; > } > > /** >@@ -172,16 +172,16 @@ > */ > void saveMetaData(IProgressMonitor monitor) > { >- if (_capabilityDomain.getMetaDataDescriptor() != null) >- { >- PropertyMetaDataDescriptor propertyMetaDataDescriptor = _capabilityDomain >- .getMetaDataDescriptor(); >- String metadataDescriptorName = _capabilityDomain.getCapability() >- .getName() >- + "Descriptor"; >- propertyMetaDataDescriptor >- .setMetadataDescriptorName(metadataDescriptorName); >- } >+ if (_capabilityDomain.getCapability().getMetadata() != null) >+ { >+ MetadataDescriptor propertyMetaDataDescriptor = _capabilityDomain.getCapability().getMetadata(); >+ String metadataDescriptorName = _capabilityDomain.getCapability() >+ .getName() >+ + "Descriptor"; >+ propertyMetaDataDescriptor >+ .setMetadataDescriptorName(metadataDescriptorName); >+ propertyMetaDataDescriptor.saveMetrics(); >+ } > } > > /** >@@ -189,21 +189,21 @@ > */ > void saveSchemas(IProgressMonitor monitor) > { >- List propertySchemas = _capabilityDomain.getPropertiesSchemas(); >- if (propertySchemas == null || propertySchemas.size() == 0) >- return; >- >- for (int i = 0; i < propertySchemas.size(); i++) >- { >- XSDSchema propertySchema = (XSDSchema) propertySchemas.get(i); >- if (propertySchema != null) >- { >- String locationURI = propertySchema.getSchemaLocation(); >- if (locationURI.endsWith("xsd")) >- XsdUtils.serializeAndFormatXSD(propertySchema, locationURI, >- false, monitor); >- } >- } >+ List propertySchemas = _capabilityDomain.getPropertiesSchemas(); >+ if (propertySchemas == null || propertySchemas.size() == 0) >+ return; >+ >+ for (int i = 0; i < propertySchemas.size(); i++) >+ { >+ XSDSchema propertySchema = (XSDSchema) propertySchemas.get(i); >+ if (propertySchema != null) >+ { >+ String locationURI = propertySchema.getSchemaLocation(); >+ if (locationURI.endsWith("xsd")) >+ XsdUtils.serializeAndFormatXSD(propertySchema, locationURI, >+ false, monitor); >+ } >+ } > } > > /** >@@ -211,20 +211,19 @@ > */ > void saveTopics(IProgressMonitor monitor) > { >- PropertyMetaDataDescriptor propertyMetaDataDescriptor = _capabilityDomain >- .getMetaDataDescriptor(); >- if (propertyMetaDataDescriptor != null) >- { >- List topicSpaces = _capabilityDomain.getCapability() >- .getTopicSpaces(); >- propertyMetaDataDescriptor.saveTopicSpaces(topicSpaces); >- PortType pt = WsdlUtils.getPortType(_capabilityDomain >- .getDefinition()); >- String rmdFileName = pt.getElement().getAttributeNS( >- WsdmConstants.WSRMD_NS, >- WsdlUtils.METADATA_DESCRIPTOR_LOCATION_KEY); >- propertyMetaDataDescriptor.save(monitor); >- } >+ MetadataDescriptor propertyMetaDataDescriptor = _capabilityDomain.getCapability().getMetadata(); >+ if (propertyMetaDataDescriptor != null) >+ { >+ List topicSpaces = _capabilityDomain.getCapability() >+ .getTopicSpaces(); >+ propertyMetaDataDescriptor.saveTopicSpaces(topicSpaces); >+ PortType pt = WsdlUtils.getPortType(_capabilityDomain.getCapability() >+ .getDefinition()); >+ String rmdFileName = pt.getElement().getAttributeNS( >+ WsdmConstants.WSRMD_NS, >+ WsdlUtils.METADATA_DESCRIPTOR_LOCATION_KEY); >+ MetaDataUtils.save(propertyMetaDataDescriptor, monitor); >+ } > } > > /** >@@ -232,43 +231,43 @@ > */ > void saveWSDL(IProgressMonitor monitor) > { >- ensureWSRFNamespaces(); >- Definition wsdlDefinition = _capabilityDomain.getDefinition(); >- String wsdlURI = wsdlDefinition.eResource().getURI().toString(); >- ByteArrayOutputStream baos = null; >- try >- { >- baos = WsdlUtils.saveWSDLDefinition( >- wsdlDefinition, wsdlURI, null); >- } catch (IOException e1) >- { >- WsdmToolingLog.logError(Messages.FAILED_TO_SAVE_MCAP_FILE_ERROR_ + " ", e1); >- } >- >- Document doc = CapUtils.parseToDOM(baos.toString()); >- String serialized = CapUtils.prettySerializeDocument(doc); >- ByteArrayInputStream baInputStream = new ByteArrayInputStream( >- serialized.getBytes()); >- >- try >- { >- IFile wsdlFile = EclipseUtils.getIFile(wsdlURI); >- wsdlFile.setContents(baInputStream, IFile.FORCE, monitor); >- } catch (CoreException e) >- { >- WsdmToolingLog.logError(Messages.FAILED_TO_SAVE_MCAP_FILE_ERROR_ + " ", e); >- } >+ ensureWSRFNamespaces(); >+ Definition wsdlDefinition = _capabilityDomain.getCapability().getDefinition(); >+ String wsdlURI = wsdlDefinition.eResource().getURI().toString(); >+ ByteArrayOutputStream baos = null; >+ try >+ { >+ baos = WsdlUtils.saveWSDLDefinition( >+ wsdlDefinition, wsdlURI, null); >+ } catch (IOException e1) >+ { >+ WsdmToolingLog.logError(Messages.FAILED_TO_SAVE_MCAP_FILE_ERROR_ + " ", e1); >+ } >+ >+ Document doc = CapUtils.parseToDOM(baos.toString()); >+ String serialized = CapUtils.documentToString(doc); >+ ByteArrayInputStream baInputStream = new ByteArrayInputStream( >+ serialized.getBytes()); >+ >+ try >+ { >+ IFile wsdlFile = EclipseUtils.getIFile(wsdlURI); >+ wsdlFile.setContents(baInputStream, IFile.FORCE, monitor); >+ } catch (CoreException e) >+ { >+ WsdmToolingLog.logError(Messages.FAILED_TO_SAVE_MCAP_FILE_ERROR_ + " ", e); >+ } > } > > private void ensureWSRFNamespaces() > { >- Definition definition = _capabilityDomain.getDefinition(); >- if (_capabilityDomain.getResourcePropertyElement() != null) >- WsdlUtils.createOrFindPrefix(definition, WsdmConstants.WSRP_NS, >- "wsrp"); >- if (_capabilityDomain.getMetaDataDescriptor() != null) >- WsdlUtils.createOrFindPrefix(definition, WsdmConstants.WSRMD_NS, >- "wsrmd"); >+ Definition definition = _capabilityDomain.getCapability().getDefinition(); >+ if (_capabilityDomain.getResourcePropertyElement() != null) >+ WsdlUtils.createOrFindPrefix(definition, WsdmConstants.WSRP_NS, >+ "wsrp"); >+ if (_capabilityDomain.getCapability().getMetadata() != null) >+ WsdlUtils.createOrFindPrefix(definition, WsdmConstants.WSRMD_NS, >+ "wsrmd"); > } > > /** >@@ -276,8 +275,8 @@ > */ > boolean loadWSDLSourcePage() > { >- //return true; >- return false; >+ //return true; >+ return false; > } > > /** >@@ -285,8 +284,8 @@ > */ > boolean loadRMDSourcePage() > { >- // return _capabilityDomain.getMetaDataDescriptor()!=null; >- return false; >+ // return _capabilityDomain.getMetaDataDescriptor()!=null; >+ return false; > } > > /** >@@ -294,8 +293,8 @@ > */ > boolean loadXSDSourcePage() > { >- // return _capabilityDomain.getResourcePropertyElement()!=null; >- return false; >+ // return _capabilityDomain.getResourcePropertyElement()!=null; >+ return false; > } > > /** >@@ -323,21 +322,21 @@ > */ > void updateWSDLSourceFromForm() > { >- IFileEditorInput modelFile = (IFileEditorInput) getEditorInput(); >- String uri = modelFile.getFile().getFullPath().toString(); >- ensureWSRFNamespaces(); >- ByteArrayOutputStream baos; >- try >- { >- baos = WsdlUtils.saveWSDLDefinition( >- _capabilityDomain.getDefinition(), uri, null); >- } catch (IOException e) >- { >- return; >- } >- Document doc = CapUtils.parseToDOM(baos.toString()); >- String serialized = CapUtils.prettySerializeDocument(doc); >- _wsdlSourcePage.setText(serialized); >+ IFileEditorInput modelFile = (IFileEditorInput) getEditorInput(); >+ String uri = modelFile.getFile().getFullPath().toString(); >+ ensureWSRFNamespaces(); >+ ByteArrayOutputStream baos; >+ try >+ { >+ baos = WsdlUtils.saveWSDLDefinition( >+ _capabilityDomain.getCapability().getDefinition(), uri, null); >+ } catch (IOException e) >+ { >+ return; >+ } >+ Document doc = CapUtils.parseToDOM(baos.toString()); >+ String serialized = CapUtils.documentToString(doc); >+ _wsdlSourcePage.setText(serialized); > } > > /** >@@ -345,9 +344,9 @@ > */ > void updateXSDSourceFromForm() > { >- XSDSchema propSchema = getCapabilityDomain().getPropertySchema(); >- Document doc = propSchema.getDocument(); >- String text = XmlUtils.toString(doc); >- _xsdSourcePage.setText(text); >+ XSDSchema propSchema = getCapabilityDomain().getPropertySchema(); >+ Document doc = propSchema.getDocument(); >+ String text = CapUtils.documentToString(doc); >+ _xsdSourcePage.setText(text); > } > } >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/internal/FormMetric.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.editor.capability/src/org/eclipse/tptp/wsdm/tooling/editor/capability/internal/FormMetric.java,v >retrieving revision 1.3 >diff -u -r1.3 FormMetric.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/capability/internal/FormMetric.java 9 Jan 2007 19:51:44 -0000 1.3 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/internal/FormMetric.java 20 Jan 2007 13:33:34 -0000 >@@ -12,25 +12,17 @@ > > package org.eclipse.tptp.wsdm.tooling.editor.capability.internal; > >-import java.util.Iterator; >- >-import org.eclipse.emf.ecore.EStructuralFeature; >-import org.eclipse.emf.ecore.impl.EStructuralFeatureImpl; > import org.eclipse.emf.ecore.resource.ResourceSet; > import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; > import org.eclipse.emf.ecore.util.BasicExtendedMetaData; > import org.eclipse.emf.ecore.util.ExtendedMetaData; >-import org.eclipse.emf.ecore.util.FeatureMap; >-import org.eclipse.emf.ecore.xml.type.internal.QName; >-import org.eclipse.emf.ecore.xml.type.internal.XMLDuration; >+import org.eclipse.emf.ecore.xmi.XMLResource; > import org.eclipse.tptp.wsdm.tooling.editor.capability.util.internal.MetaDataUtils; >+import org.eclipse.tptp.wsdm.tooling.model.capabilities.CapabilitiesFactory; >+import org.eclipse.tptp.wsdm.tooling.model.capabilities.Metrics; > import org.eclipse.tptp.wsdm.tooling.model.capabilities.Property; >+import org.eclipse.tptp.wsdm.tooling.model.capabilities.impl.MetadataDescriptor; > import org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.PropertyType; >-import org.eclipse.tptp.wsdm.tooling.model.muwsPart2.ChangeTypeType; >-import org.eclipse.tptp.wsdm.tooling.model.muwsPart2.GatheringTimeType; >-import org.eclipse.tptp.wsdm.tooling.model.muwsPart2.TimeScopeType; >-import org.eclipse.tptp.wsdm.tooling.util.internal.PropertyMetaDataDescriptor; >-import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmConstants; > import org.eclipse.tptp.wsdm.tooling.util.internal.XsdUtils; > > /** >@@ -63,13 +55,13 @@ > > public static final String[] COLUMN_NAMES = new String[] { CTYPE_COL, TSCOPE_COL, GTIME_COL, CINTERVAL_COL, GROUP_COL }; > >- private ChangeTypeType _changeType; >+ private String _changeType; > >- private TimeScopeType _timeScope; >+ private String _timeScope; > >- private GatheringTimeType _gatheringTime; >+ private String _gatheringTime; > >- private XMLDuration _calculationInterval; >+ private String _calculationInterval; > > private PropertyType _metadata; > >@@ -93,18 +85,25 @@ > _capabilityDomain = capabilityDomain; > _property = property; > _metadata = property.getMetaData(); >- _extendedMetaData = createExtendedMetaData(); >+ _extendedMetaData = createExtendedMetaData(); >+ if(property.getMetrics()!=null) >+ { >+ _changeType = property.getMetrics().getChangeType(); >+ _timeScope = property.getMetrics().getTimeScope(); >+ _gatheringTime = property.getMetrics().getGatheringTime(); >+ _calculationInterval = property.getMetrics().getCalculationInterval(); >+ } > } > > private PropertyType createNewPropertyMetadata() > { >- PropertyMetaDataDescriptor propertyMetaDataDescriptor = _capabilityDomain.getMetaDataDescriptor(); >+ MetadataDescriptor propertyMetaDataDescriptor = _capabilityDomain.getCapability().getMetadata(); > PropertyType metadata = propertyMetaDataDescriptor.createNewPropertyType(); > _property.setMetaData(metadata); > String ns = _property.getElement().getTargetNamespace(); > String name = XsdUtils.getName(_property.getElement()); > String prefix = propertyMetaDataDescriptor.getOrCreatePrefix(ns); >- metadata.setName(new QName(ns,name,prefix)); >+ metadata.setName(prefix+":"+name); > return metadata; > } > >@@ -112,7 +111,8 @@ > { > ResourceSet resourceSet = new ResourceSetImpl(); > ExtendedMetaData extendedMetaData = new BasicExtendedMetaData(resourceSet.getPackageRegistry()); >- return extendedMetaData; >+ resourceSet.getLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, extendedMetaData); >+ return extendedMetaData; > } > > /** >@@ -122,7 +122,7 @@ > { > if(_calculationInterval == null) > return ""; >- return _calculationInterval.toString(); >+ return _calculationInterval; > } > > /** >@@ -132,7 +132,7 @@ > { > if(_changeType == null) > return ""; >- return _changeType.getLiteral(); >+ return _changeType; > } > > /** >@@ -142,7 +142,7 @@ > { > if(_gatheringTime == null) > return ""; >- return _gatheringTime.getLiteral(); >+ return _gatheringTime; > } > > /** >@@ -152,7 +152,7 @@ > { > if(_timeScope == null) > return ""; >- return _timeScope.getLiteral(); >+ return _timeScope; > } > > /** >@@ -201,7 +201,7 @@ > */ > public void setColumnObject(String column, Object value) > { >- if(_capabilityDomain.getMetaDataDescriptor() == null) >+ if(_capabilityDomain.getCapability().getMetadata() == null) > MetaDataUtils.createMetaDataDescriptor(_capabilityDomain); > > if(_metadata == null) >@@ -209,31 +209,28 @@ > > if (column.equals(CTYPE_COL)) > { >- removeOldEntry(ChangeTypeType.class); > String newChangeType = CTYPE_STR_ENUM[((Integer) value).intValue()]; >- EStructuralFeature _changeTypeESF = _extendedMetaData.demandFeature(WsdmConstants.MUWS_P2_NS, MetaDataUtils.CHANGE_TYPE, false); >- ChangeTypeType changeTypeType = MetaDataUtils.getChangeTypeType(newChangeType); >- createNewEntry(_changeTypeESF,changeTypeType); >+ createMetricsIfRequired(); >+ _property.getMetrics().setChangeType(newChangeType); >+ _changeType = newChangeType; > return; > } > > if (column.equals(TSCOPE_COL)) > { >- removeOldEntry(TimeScopeType.class); > String newTimeScope = TSCOPE_STR_ENUM[((Integer) value).intValue()]; >- EStructuralFeature _timeScopeESF = _extendedMetaData.demandFeature(WsdmConstants.MUWS_P2_NS, MetaDataUtils.TIME_SCOPE, false); >- TimeScopeType timeScopeType = MetaDataUtils.getTimeScopeType(newTimeScope); >- createNewEntry(_timeScopeESF,timeScopeType); >+ createMetricsIfRequired(); >+ _property.getMetrics().setTimeScope(newTimeScope); >+ _timeScope = newTimeScope; > return; > } > > if (column.equals(GTIME_COL)) > { >- removeOldEntry(GatheringTimeType.class); > String newGTime = GTIME_STR_ENUM[((Integer) value).intValue()]; >- EStructuralFeature _gatheringTimeESF = _extendedMetaData.demandFeature(WsdmConstants.MUWS_P2_NS, MetaDataUtils.GATHERING_TIME, false); >- GatheringTimeType gatheringTimeType = MetaDataUtils.getGatheringTimeType(newGTime); >- createNewEntry(_gatheringTimeESF,gatheringTimeType); >+ createMetricsIfRequired(); >+ _property.getMetrics().setGatheringTime(newGTime); >+ _gatheringTime = newGTime; > return; > } > >@@ -242,49 +239,21 @@ > String newCInterval = (String)value; > if(newCInterval.equals("") || newCInterval.toUpperCase().equals("P")) > return; >- removeOldEntry(XMLDuration.class); >- EStructuralFeature _calculationIntervalESF = _extendedMetaData.demandFeature(WsdmConstants.MUWS_P2_NS, MetaDataUtils.CALCULATION_INTERVAL, false); >- XMLDuration duration = new XMLDuration(newCInterval); >- createNewEntry(_calculationIntervalESF,duration); >+ createMetricsIfRequired(); >+ _property.getMetrics().setCalculationInterval(newCInterval); >+ _calculationInterval = newCInterval; > } > } > >- private void createNewEntry(EStructuralFeature esf, Object value) >- { >- createMetricsCapabilityEntry(); >- FeatureMap fm = _metadata.getAny(); >- fm.add(esf, value); >- } >- >- private void removeOldEntry(Class typeClass) >+ private void createMetricsIfRequired() > { >- FeatureMap fm = _metadata.getAny(); >- Iterator it = fm.iterator(); >- while (it.hasNext()) >+ if(_property.getMetrics() == null) > { >- Object obj = it.next(); >- if (obj instanceof EStructuralFeatureImpl.SimpleFeatureMapEntry) >- { >- EStructuralFeatureImpl.SimpleFeatureMapEntry entry = (EStructuralFeatureImpl.SimpleFeatureMapEntry) obj; >- if(typeClass.isInstance(entry.getValue())) >- { >- fm.remove(entry); >- return; >- } >- } >+ Metrics metrics = CapabilitiesFactory.eINSTANCE.createMetrics(); >+ _property.setMetrics(metrics); > } > } > >- private void createMetricsCapabilityEntry() >- { >- if(!MetaDataUtils.hasMetricsCapability(_metadata)) >- { >- FeatureMap fm = _metadata.getAny(); >- EStructuralFeature esf = _extendedMetaData.demandFeature(WsdmConstants.MUWS_P2_NS, "Capability", false); >- fm.add(esf, WsdmConstants.MUWS_METRICS_NS); >- } >- } >- > /** > * Returns the metric property for selected column. > */ >@@ -309,38 +278,5 @@ > return new Integer(i); > } > return new Integer(0); >- } >- >- /** >- * Sets the change type for this metric. >- */ >- public void setChangeType(ChangeTypeType changeType) >- { >- _changeType = changeType; >- } >- >- /** >- * Sets the time scope for this metric. >- */ >- public void setTimeScope(TimeScopeType timeScope) >- { >- _timeScope = timeScope; >- } >- >- /** >- * Sets the gathering time for this metric. >- */ >- public void setGatheringTime(GatheringTimeType gatheringTime) >- { >- _gatheringTime = gatheringTime; >- } >- >- /** >- * Sets the calculation interval for this metric. >- */ >- public void setCalculationInterval(XMLDuration calculationInterval) >- { >- _calculationInterval = calculationInterval; >- } >- >+ } > } >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/internal/CapabilityDomain.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.editor.capability/src/org/eclipse/tptp/wsdm/tooling/editor/capability/internal/CapabilityDomain.java,v >retrieving revision 1.5 >diff -u -r1.5 CapabilityDomain.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/capability/internal/CapabilityDomain.java 9 Jan 2007 19:51:44 -0000 1.5 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/internal/CapabilityDomain.java 20 Jan 2007 13:33:33 -0000 >@@ -15,10 +15,9 @@ > import java.util.ArrayList; > import java.util.List; > >+import org.eclipse.core.resources.IFile; > import org.eclipse.tptp.wsdm.tooling.model.Activator; > import org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability; >-import org.eclipse.tptp.wsdm.tooling.util.internal.PropertyMetaDataDescriptor; >-import org.eclipse.wst.wsdl.Definition; > import org.eclipse.xsd.XSDElementDeclaration; > import org.eclipse.xsd.XSDSchema; > import org.osgi.framework.Bundle; >@@ -37,19 +36,17 @@ > > private Capability _capability; > >- private Definition _definition; >- > private XSDSchema _propertySchema; > > private List _propertiesSchemas; > > private XSDElementDeclaration _resourcePropertyElement; > >- private PropertyMetaDataDescriptor _metaDataDescriptor; >- > private Bundle _modelPlugin; > > private Text _descriptionNode; >+ >+ private IFile _capabilityFile; > > /** > * Creates a new object of this class. >@@ -57,8 +54,8 @@ > */ > public CapabilityDomain() > { >- _modelPlugin = Activator.getDefault().getBundle(); >- _propertiesSchemas = new ArrayList(); >+ _modelPlugin = Activator.getDefault().getBundle(); >+ _propertiesSchemas = new ArrayList(); > } > > /** >@@ -66,23 +63,23 @@ > */ > public Capability getCapability() > { >- return _capability; >+ return _capability; > } >- >+ > /** >- * Returns the wsdl definition of capability domain. >+ * Returns the capability file. > */ >- public Definition getDefinition() >+ public IFile getCapabilityIFile() > { >- return _definition; >+ return _capabilityFile; > } >- >+ > /** > * Returns the property schema of capability. > */ > public XSDSchema getPropertySchema() > { >- return _propertySchema; >+ return _propertySchema; > } > > /** >@@ -90,15 +87,7 @@ > */ > public XSDElementDeclaration getResourcePropertyElement() > { >- return _resourcePropertyElement; >- } >- >- /** >- * Returns the propertyMetaDataDescriptor of capability domain. >- */ >- public PropertyMetaDataDescriptor getMetaDataDescriptor() >- { >- return _metaDataDescriptor; >+ return _resourcePropertyElement; > } > > /** >@@ -106,7 +95,7 @@ > */ > public Text getDescriptionNode() > { >- return _descriptionNode; >+ return _descriptionNode; > } > > /** >@@ -114,7 +103,7 @@ > */ > public List getPropertiesSchemas() > { >- return _propertiesSchemas; >+ return _propertiesSchemas; > } > > /** >@@ -122,7 +111,7 @@ > */ > public Bundle getModelPlugin() > { >- return _modelPlugin; >+ return _modelPlugin; > } > > /** >@@ -130,7 +119,7 @@ > */ > public void addPropertySchema(XSDSchema schema) > { >- _propertiesSchemas.add(schema); >+ _propertiesSchemas.add(schema); > } > > /** >@@ -138,25 +127,25 @@ > */ > public void setCapability(Capability capability) > { >- _capability = capability; >+ _capability = capability; > } >- >+ > /** >- * Sets the wsdl definition for capability domain. >+ * Sets the capability file. > */ >- public void setDefinition(Definition definition) >+ public void setCapabilityIFile(IFile capabilityFile) > { >- _definition = definition; >+ _capabilityFile = capabilityFile; > } >- >+ > /** > * Sets the property schema for capability. > */ > public void setPropertySchema(XSDSchema propertySchema) > { >- _propertySchema = propertySchema; >- if(!getPropertiesSchemas().contains(_propertySchema)) >- addPropertySchema(_propertySchema); >+ _propertySchema = propertySchema; >+ if(!getPropertiesSchemas().contains(_propertySchema)) >+ addPropertySchema(_propertySchema); > } > > /** >@@ -165,17 +154,7 @@ > public void setResourcePropertyElement( > XSDElementDeclaration resourcePropertyElement) > { >- _resourcePropertyElement = resourcePropertyElement; >- } >- >- /** >- * Sets the propertyMetaDataDescriptor for capability domain. >- */ >- public void setMetaDataDescriptor( >- PropertyMetaDataDescriptor metaDataDescriptor) >- { >- >- _metaDataDescriptor = metaDataDescriptor; >+ _resourcePropertyElement = resourcePropertyElement; > } > > /** >@@ -183,7 +162,7 @@ > */ > public void setDescriptionNode(Text node) > { >- _descriptionNode = node; >+ _descriptionNode = node; > } > > } >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/internal/AbstractCapabilityEditor.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.editor.capability/src/org/eclipse/tptp/wsdm/tooling/editor/capability/internal/AbstractCapabilityEditor.java,v >retrieving revision 1.10 >diff -u -r1.10 AbstractCapabilityEditor.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/capability/internal/AbstractCapabilityEditor.java 9 Jan 2007 19:51:44 -0000 1.10 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/internal/AbstractCapabilityEditor.java 20 Jan 2007 13:33:33 -0000 >@@ -30,14 +30,15 @@ > import org.eclipse.tptp.wsdm.tooling.editor.ui.internal.IUIPage; > import org.eclipse.tptp.wsdm.tooling.model.capabilities.CapabilitiesFactory; > import org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability; >+import org.eclipse.tptp.wsdm.tooling.model.capabilities.Metrics; > import org.eclipse.tptp.wsdm.tooling.model.capabilities.Property; >+import org.eclipse.tptp.wsdm.tooling.model.capabilities.impl.MetadataDescriptor; > import org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.DocumentRoot; > import org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.PropertyType; > import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.internal.Messages; > import org.eclipse.tptp.wsdm.tooling.util.internal.CapUtils; > import org.eclipse.tptp.wsdm.tooling.util.internal.EclipseUtils; > import org.eclipse.tptp.wsdm.tooling.util.internal.IResourceChangeConsumer; >-import org.eclipse.tptp.wsdm.tooling.util.internal.PropertyMetaDataDescriptor; > import org.eclipse.tptp.wsdm.tooling.util.internal.ResourceChangeListener; > import org.eclipse.tptp.wsdm.tooling.util.internal.WsdlUtils; > import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmToolingLog; >@@ -117,32 +118,32 @@ > */ > protected void createPages() > { >- buildModel(); >- _overviewPage = createOverviewPage(); >- >- _propertyPage = createPropertyPage(); >- >- _operationPage = createOperationPage(); >- >- _topicPage = createTopicPage(); >- >- if (loadWSDLSourcePage()) >- { >- _wsdlSourcePage = createWSDLSourcePage(); >- _create_wsdl_source = true; >- } >- if (loadXSDSourcePage()) >- { >- _xsdSourcePage = createXSDSourcePage(); >- _create_xsd_source = true; >- } >- if (loadRMDSourcePage()) >- { >- _rmdSourcePage = createRMDSourcePage(); >- _create_rmd_source = true; >- } >- firePropertyChange(IEditorPart.PROP_DIRTY); >- hookAllListeners(); >+ buildModel(); >+ _overviewPage = createOverviewPage(); >+ >+ _propertyPage = createPropertyPage(); >+ >+ _operationPage = createOperationPage(); >+ >+ _topicPage = createTopicPage(); >+ >+ if (loadWSDLSourcePage()) >+ { >+ _wsdlSourcePage = createWSDLSourcePage(); >+ _create_wsdl_source = true; >+ } >+ if (loadXSDSourcePage()) >+ { >+ _xsdSourcePage = createXSDSourcePage(); >+ _create_xsd_source = true; >+ } >+ if (loadRMDSourcePage()) >+ { >+ _rmdSourcePage = createRMDSourcePage(); >+ _create_rmd_source = true; >+ } >+ firePropertyChange(IEditorPart.PROP_DIRTY); >+ hookAllListeners(); > } > > abstract IUIPage createOverviewPage(); >@@ -184,17 +185,17 @@ > */ > protected void hookAllListeners() > { >- _overviewPage.hookAllListeners(); >- _propertyPage.hookAllListeners(); >- _operationPage.hookAllListeners(); >- _topicPage.hookAllListeners(); >- if (_create_wsdl_source) >- _wsdlSourcePage.hookAllListeners(); >- if (_create_xsd_source) >- _xsdSourcePage.hookAllListeners(); >- if (_create_rmd_source) >- _rmdSourcePage.hookAllListeners(); >- _resourceChangeListener.addResourceChangeConsumer(this); >+ _overviewPage.hookAllListeners(); >+ _propertyPage.hookAllListeners(); >+ _operationPage.hookAllListeners(); >+ _topicPage.hookAllListeners(); >+ if (_create_wsdl_source) >+ _wsdlSourcePage.hookAllListeners(); >+ if (_create_xsd_source) >+ _xsdSourcePage.hookAllListeners(); >+ if (_create_rmd_source) >+ _rmdSourcePage.hookAllListeners(); >+ _resourceChangeListener.addResourceChangeConsumer(this); > } > > /** >@@ -202,21 +203,21 @@ > */ > public void doSave(IProgressMonitor monitor) > { >- if (_overviewPage.isDirty() || _propertyPage.isDirty() >- || _operationPage.isDirty() || _topicPage.isDirty()) >- { >- saveSchemas(monitor); >- saveMetaData(monitor); >- saveTopics(monitor); >- saveWSDL(monitor); >- >- _overviewPage.save(); >- _propertyPage.save(); >- _operationPage.save(); >- _topicPage.save(); >- } >- >- firePropertyChange(IEditorPart.PROP_DIRTY); >+ if (_overviewPage.isDirty() || _propertyPage.isDirty() >+ || _operationPage.isDirty() || _topicPage.isDirty()) >+ { >+ saveSchemas(monitor); >+ saveMetaData(monitor); >+ saveTopics(monitor); >+ saveWSDL(monitor); >+ >+ _overviewPage.save(); >+ _propertyPage.save(); >+ _operationPage.save(); >+ _topicPage.save(); >+ } >+ >+ firePropertyChange(IEditorPart.PROP_DIRTY); > } > > /** >@@ -231,7 +232,7 @@ > */ > public boolean isSaveAsAllowed() > { >- return false; >+ return false; > } > > /** >@@ -239,26 +240,26 @@ > */ > public boolean isDirty() > { >- if (super.isDirty()) >- return true; >- if (isSourcePagesDirty()) >- return true; >- return (_overviewPage.isDirty() || _propertyPage.isDirty() >- || _operationPage.isDirty() || _topicPage.isDirty()); >+ if (super.isDirty()) >+ return true; >+ if (isSourcePagesDirty()) >+ return true; >+ return (_overviewPage.isDirty() || _propertyPage.isDirty() >+ || _operationPage.isDirty() || _topicPage.isDirty()); > } > > private boolean isSourcePagesDirty() > { >- boolean wsdlSourceDirty = false; >- boolean xsdSourceDirty = false; >- boolean rmdSourceDirty = false; >- if (_create_wsdl_source) >- wsdlSourceDirty = _wsdlSourcePage.isDirty(); >- if (_create_xsd_source) >- xsdSourceDirty = _xsdSourcePage.isDirty(); >- if (_create_rmd_source) >- rmdSourceDirty = _rmdSourcePage.isDirty(); >- return wsdlSourceDirty || xsdSourceDirty || rmdSourceDirty; >+ boolean wsdlSourceDirty = false; >+ boolean xsdSourceDirty = false; >+ boolean rmdSourceDirty = false; >+ if (_create_wsdl_source) >+ wsdlSourceDirty = _wsdlSourcePage.isDirty(); >+ if (_create_xsd_source) >+ xsdSourceDirty = _xsdSourcePage.isDirty(); >+ if (_create_rmd_source) >+ rmdSourceDirty = _rmdSourcePage.isDirty(); >+ return wsdlSourceDirty || xsdSourceDirty || rmdSourceDirty; > } > > /** >@@ -272,217 +273,241 @@ > */ > protected void buildModel() > { >- _capabilityDomain = new CapabilityDomain(); >- Capability capability = CapabilitiesFactory.eINSTANCE >- .createCapability(); >- _capabilityDomain.setCapability(capability); >- Definition wsdlDefinition = null; >- if(getEditorInput() instanceof IFileEditorInput) >- { >- IFileEditorInput modelFileInput = (IFileEditorInput) getEditorInput(); >- IFile capabilityFile = modelFileInput.getFile(); >- try { >- wsdlDefinition = WsdlUtils.getWSDLDefinition(capabilityFile); >- } catch (Exception e) { >- 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 { >- wsdlDefinition = WsdlUtils.getWSDLDefinition(capFileURI); >- } catch (Exception e) { >- WsdmToolingLog.logError(Messages.IMPROPER_WSDL_FILE_ERROR_,e); >- return; >- } >- } >- else >- return; >+ _capabilityDomain = new CapabilityDomain(); >+ Capability capability = CapabilitiesFactory.eINSTANCE >+ .createCapability(); >+ _capabilityDomain.setCapability(capability); >+ Definition wsdlDefinition = null; >+ if(getEditorInput() instanceof IFileEditorInput) >+ { >+ IFileEditorInput modelFileInput = (IFileEditorInput) getEditorInput(); >+ IFile capabilityFile = modelFileInput.getFile(); >+ _capabilityDomain.setCapabilityIFile(capabilityFile); >+ try >+ { >+ wsdlDefinition = WsdlUtils.getWSDLDefinition(capabilityFile); >+ } >+ catch (Exception e) >+ { >+ 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 >+ { >+ wsdlDefinition = WsdlUtils.getWSDLDefinition(capFileURI); >+ } >+ catch (Exception e) >+ { >+ WsdmToolingLog.logError(Messages.IMPROPER_WSDL_FILE_ERROR_,e); >+ return; >+ } >+ } >+ else >+ return; >+ >+ _capabilityDomain.getCapability().setDefinition(wsdlDefinition); >+ >+ Map metadataMap = WsdlUtils.getMetadataFromPortType(wsdlDefinition); >+ String resourceProperties = (String) metadataMap >+ .get(WsdlUtils.RESOURCE_PROPERTIES_ELEMENT_KEY); >+ if (resourceProperties != null) >+ { >+ XSDElementDeclaration resourcePropertyElement = WsdlUtils >+ .getResourcePropertyElement(wsdlDefinition, >+ resourceProperties); >+ _capabilityDomain >+ .setResourcePropertyElement(resourcePropertyElement); >+ List xsdSchemas = CapUtils.getPropertiesSchemas(wsdlDefinition, >+ resourcePropertyElement); > >- _capabilityDomain.setDefinition(wsdlDefinition); >+ { >+ // Extract the proper properties schema for capability >+ XSDSchema tnsSchema = WsdlUtils.getSchema(wsdlDefinition, >+ resourcePropertyElement.getSchema() >+ .getTargetNamespace()); >+ XSDInclude include = XsdUtils.getFirstXSDInclude(tnsSchema); >+ if (include != null) >+ _capabilityDomain.setPropertySchema(include >+ .getResolvedSchema()); >+ else if (xsdSchemas.size() != 0) >+ { >+ XSDSchema propSchema = (XSDSchema) xsdSchemas.get(0); >+ _capabilityDomain.setPropertySchema(propSchema); >+ } >+ } > >- Map metadataMap = WsdlUtils.getMetadataFromPortType(wsdlDefinition); >- String resourceProperties = (String) metadataMap >- .get(WsdlUtils.RESOURCE_PROPERTIES_ELEMENT_KEY); >- if (resourceProperties != null) >- { >- XSDElementDeclaration resourcePropertyElement = WsdlUtils >- .getResourcePropertyElement(wsdlDefinition, >- resourceProperties); >- _capabilityDomain >- .setResourcePropertyElement(resourcePropertyElement); >- List xsdSchemas = CapUtils.getPropertiesSchemas(wsdlDefinition, >- resourcePropertyElement); >- >- { >- // Extract the proper properties schema for capability >- XSDSchema tnsSchema = WsdlUtils.getSchema(wsdlDefinition, >- resourcePropertyElement.getSchema() >- .getTargetNamespace()); >- XSDInclude include = XsdUtils.getFirstXSDInclude(tnsSchema); >- if (include != null) >- _capabilityDomain.setPropertySchema(include >- .getResolvedSchema()); >- else if (xsdSchemas.size() != 0) >- { >- XSDSchema propSchema = (XSDSchema) xsdSchemas.get(0); >- _capabilityDomain.setPropertySchema(propSchema); >- } >- } >- >- for (int i = 0; i < xsdSchemas.size(); i++) >- { >- XSDSchema schema = (XSDSchema) xsdSchemas.get(i); >- _capabilityDomain.addPropertySchema(schema); >- } >- } >- >- String metadataDescriptorLocation = (String) metadataMap >- .get(WsdlUtils.METADATA_DESCRIPTOR_LOCATION_KEY); >- String metadataDescriptorName = (String) metadataMap >- .get(WsdlUtils.METADATA_DESCRIPTOR_KEY); >- DocumentRoot rmdRoot = null; >- if (metadataDescriptorLocation != null >- && metadataDescriptorName != null) >- { >- >- String rmdFileLocation = _capabilityDomain.getDefinition().eResource().getURI().trimSegments(1)+"/" + metadataDescriptorLocation; >- rmdRoot = MetaDataUtils.getDocumentRoot(URI.createURI(rmdFileLocation)); >- if(rmdRoot!=null) >- if(_capabilityDomain.getMetaDataDescriptor()!=null) >- _capabilityDomain.getMetaDataDescriptor().setDocumentRoot(rmdRoot); >- } >- >- Definition definition = _capabilityDomain.getDefinition(); >- XSDSchema propSchema = _capabilityDomain.getPropertySchema(); >- buildModel(definition, propSchema, rmdRoot); >+ for (int i = 0; i < xsdSchemas.size(); i++) >+ { >+ XSDSchema schema = (XSDSchema) xsdSchemas.get(i); >+ _capabilityDomain.addPropertySchema(schema); >+ } >+ } >+ >+ String metadataDescriptorLocation = (String) metadataMap >+ .get(WsdlUtils.METADATA_DESCRIPTOR_LOCATION_KEY); >+ String metadataDescriptorName = (String) metadataMap >+ .get(WsdlUtils.METADATA_DESCRIPTOR_KEY); >+ DocumentRoot rmdRoot = null; >+ if (metadataDescriptorLocation != null >+ && metadataDescriptorName != null) >+ { >+ >+ String rmdFileLocation = _capabilityDomain.getCapability().getDefinition().eResource().getURI().trimSegments(1)+"/" + metadataDescriptorLocation; >+ rmdRoot = MetaDataUtils.getDocumentRoot(URI.createURI(rmdFileLocation)); >+ if(rmdRoot!=null) >+ if(_capabilityDomain.getCapability().getMetadata()!=null) >+ _capabilityDomain.getCapability().getMetadata().setDocumentRoot(rmdRoot); >+ } >+ >+ Definition definition = _capabilityDomain.getCapability().getDefinition(); >+ XSDSchema propSchema = _capabilityDomain.getPropertySchema(); >+ buildModel(definition, propSchema, rmdRoot); > } > > private void buildModel(Definition definition, XSDSchema propSchema, > DocumentRoot rmdRoot) > { >- _capabilityDomain.setDefinition(definition); >- _capabilityDomain.setPropertySchema(propSchema); >- if(rmdRoot!=null) >- if(_capabilityDomain.getMetaDataDescriptor()!=null) >- _capabilityDomain.getMetaDataDescriptor().setDocumentRoot(rmdRoot); >- >- populateCapabilityInfo(); >- >- Map metadataMap = WsdlUtils.getMetadataFromPortType(definition); >- String resourceProperties = (String) metadataMap >- .get(WsdlUtils.RESOURCE_PROPERTIES_ELEMENT_KEY); >- if (resourceProperties != null) >- { >- XSDElementDeclaration resourcePropertyElement = WsdlUtils >- .getResourcePropertyElement(definition, resourceProperties); >- _capabilityDomain >- .setResourcePropertyElement(resourcePropertyElement); >- createXSDModel(); >- } >- else >- { >- _capabilityDomain.setResourcePropertyElement(null); >- } >- >- String metadataDescriptorName = (String) metadataMap >- .get(WsdlUtils.METADATA_DESCRIPTOR_KEY); >- if (rmdRoot != null) >- { >- populatePropertiesMetaData(rmdRoot, metadataDescriptorName); >- populateCapabilityTopics(); >- } >- >- populateCapabilityOperations(); >+ _capabilityDomain.getCapability().setDefinition(definition); >+ _capabilityDomain.setPropertySchema(propSchema); >+ if(rmdRoot!=null) >+ if(_capabilityDomain.getCapability().getMetadata()!=null) >+ _capabilityDomain.getCapability().getMetadata().setDocumentRoot(rmdRoot); >+ >+ populateCapabilityInfo(); >+ >+ Map metadataMap = WsdlUtils.getMetadataFromPortType(definition); >+ String resourceProperties = (String) metadataMap >+ .get(WsdlUtils.RESOURCE_PROPERTIES_ELEMENT_KEY); >+ if (resourceProperties != null) >+ { >+ XSDElementDeclaration resourcePropertyElement = WsdlUtils >+ .getResourcePropertyElement(definition, resourceProperties); >+ _capabilityDomain >+ .setResourcePropertyElement(resourcePropertyElement); >+ createXSDModel(); >+ } >+ else >+ { >+ _capabilityDomain.setResourcePropertyElement(null); >+ } >+ >+ String metadataDescriptorName = (String) metadataMap >+ .get(WsdlUtils.METADATA_DESCRIPTOR_KEY); >+ if (rmdRoot != null) >+ { >+ populatePropertiesMetaData(rmdRoot, metadataDescriptorName); >+ populateCapabilityTopics(); >+ } >+ >+ populateCapabilityOperations(); > } > > private void populateCapabilityInfo() > { >- Definition wsdlDefinition = _capabilityDomain.getDefinition(); >- Capability capability = _capabilityDomain.getCapability(); >- QName qname = wsdlDefinition.getQName(); >- String localPart = qname.getLocalPart(); >- String ns = wsdlDefinition.getTargetNamespace(); >- String prefix = wsdlDefinition.getPrefix(ns); >- Text node = CapUtils.getDescriptionNode(wsdlDefinition); >- String description = ""; >- if (node != null) >- { >- description = node.getData(); >- _capabilityDomain.setDescriptionNode(node); >- } >- capability.setNamespace(ns); >- capability.setPrefix(prefix); >- capability.setName(localPart); >- capability.setDescription(description); >+ Capability capability = _capabilityDomain.getCapability(); >+ Definition wsdlDefinition = capability.getDefinition(); >+ QName qname = wsdlDefinition.getQName(); >+ String localPart = qname.getLocalPart(); >+ String ns = wsdlDefinition.getTargetNamespace(); >+ String prefix = wsdlDefinition.getPrefix(ns); >+ Text node = CapUtils.getDescriptionNode(wsdlDefinition); >+ String description = ""; >+ if (node != null) >+ { >+ description = node.getData(); >+ _capabilityDomain.setDescriptionNode(node); >+ } >+ capability.setNamespace(ns); >+ capability.setPrefix(prefix); >+ capability.setName(localPart); >+ capability.setDescription(description); > } > > private void createXSDModel() > { >- Definition definition = _capabilityDomain.getDefinition(); >- XSDElementDeclaration resourcePropertyElement = _capabilityDomain >- .getResourcePropertyElement(); >- XSDElementDeclaration[] elements = CapUtils.getResolvedProperties( >- definition, resourcePropertyElement); >- Capability capability = _capabilityDomain.getCapability(); >- capability.getProperties().clear(); >- for (int i = 0; i < elements.length; i++) >- { >- Property property = CapabilitiesFactory.eINSTANCE.createProperty(); >- property.setElement(elements[i]); >- capability.getProperties().add(property); >- } >+ Capability capability = _capabilityDomain.getCapability(); >+ Definition definition = capability.getDefinition(); >+ XSDElementDeclaration resourcePropertyElement = _capabilityDomain >+ .getResourcePropertyElement(); >+ XSDElementDeclaration[] elements = CapUtils.getResolvedProperties( >+ definition, resourcePropertyElement); >+ capability.getProperties().clear(); >+ for (int i = 0; i < elements.length; i++) >+ { >+ Property property = CapabilitiesFactory.eINSTANCE.createProperty(); >+ property.setElement(elements[i]); >+ capability.getProperties().add(property); >+ } > } > > private void populatePropertiesMetaData(DocumentRoot root, > String metadataDescriptorName) > { >- Capability capability = _capabilityDomain.getCapability(); >- PropertyMetaDataDescriptor propertyMetaDataDescriptor = new PropertyMetaDataDescriptor( >- root, capability, metadataDescriptorName); >- _capabilityDomain.setMetaDataDescriptor(propertyMetaDataDescriptor); >- PropertyType[] propertyType = propertyMetaDataDescriptor >- .getPropertyTypes(); >- for (int i = 0; i < propertyType.length; i++) >- { >- String propertyName = ((org.eclipse.emf.ecore.xml.type.internal.QName) propertyType[i] >- .getName()).getLocalPart(); >- String namespace = ((org.eclipse.emf.ecore.xml.type.internal.QName) propertyType[i] >- .getName()).getNamespaceURI(); >- Property property = CapUtils.getProperty(capability, namespace, >- propertyName); >- if (property != null) >- property.setMetaData(propertyType[i]); >- } >+ Capability capability = _capabilityDomain.getCapability(); >+ // TODO Check this out >+ MetadataDescriptor propertyMetaDataDescriptor = new MetadataDescriptor(capability, root, metadataDescriptorName); >+ PropertyType[] propertyType = propertyMetaDataDescriptor >+ .getPropertyTypes(); >+ for (int i = 0; i < propertyType.length; i++) >+ { >+ String propName = propertyType[i].getName(); >+ String prefix = extractPrefix(propName); >+ String localName = extractName(propName); >+ String namespace = propertyMetaDataDescriptor.getNamespace(prefix); >+ Property property = CapUtils.getProperty(capability, namespace, localName); >+ if (property != null) >+ { >+ property.setMetaData(propertyType[i]); >+ Metrics metrics = propertyMetaDataDescriptor.getMetrics(propertyType[i]); >+ property.setMetrics(metrics); >+ } >+ } >+ } >+ >+ private String extractPrefix(String str) >+ { >+ if(str == null || str.trim().equals("") || str.indexOf(':') == -1) >+ return null; >+ return str.substring(0,str.indexOf(':')); >+ } >+ >+ private String extractName(String str) >+ { >+ if(str == null || str.trim().equals("") || str.indexOf(':') == -1) >+ return null; >+ return str.substring(str.indexOf(':')+1); > } > > private void populateCapabilityTopics() > { >- PropertyMetaDataDescriptor propertyMetaDataDescriptor = _capabilityDomain >- .getMetaDataDescriptor(); >- Capability capability = _capabilityDomain.getCapability(); >- List topicSpaces = propertyMetaDataDescriptor.getTopicSpaces(); >- capability.getTopicSpaces().addAll(topicSpaces); >+ Capability capability = _capabilityDomain.getCapability(); >+ MetadataDescriptor propertyMetaDataDescriptor = capability.getMetadata(); >+ propertyMetaDataDescriptor.loadTopicSpaces(); > } > > private void populateCapabilityOperations() > { >- Definition wsdlDefinition = _capabilityDomain.getDefinition(); >- Capability capability = _capabilityDomain.getCapability(); >- Operation[] operations = WsdlUtils.getWSDLOperation(wsdlDefinition); >- capability.getOperations().clear(); >- for (int i = 0; i < operations.length; i++) >- capability.getOperations().add(operations[i]); >+ Capability capability = _capabilityDomain.getCapability(); >+ Definition wsdlDefinition = capability.getDefinition(); >+ Operation[] operations = WsdlUtils.getWSDLOperation(wsdlDefinition); >+ capability.getOperations().clear(); >+ for (int i = 0; i < operations.length; i++) >+ capability.getOperations().add(operations[i]); > } > > /** >@@ -491,7 +516,7 @@ > */ > public void setDirty() > { >- firePropertyChange(IEditorPart.PROP_DIRTY); >+ firePropertyChange(IEditorPart.PROP_DIRTY); > } > > /** >@@ -499,7 +524,7 @@ > */ > public void setActivePage(int index) > { >- super.setActivePage(index); >+ super.setActivePage(index); > } > > /** >@@ -510,7 +535,7 @@ > */ > public CapabilityDomain getCapabilityDomain() > { >- return _capabilityDomain; >+ return _capabilityDomain; > } > > /** >@@ -518,18 +543,18 @@ > */ > protected void pageChange(int newPageIndex) > { >- for(int i=0;i<_pages.size();i++) >- { >- IPage page = (IPage) _pages.get(i); >- page.pageChange(newPageIndex); >- } >- if (newPageIndex == _wsdlSourcePageIndex) >- updateWSDLSourceFromForm(); >- else if (newPageIndex == _xsdSourcePageIndex) >- updateXSDSourceFromForm(); >- else if (newPageIndex == _rmdSourcePageIndex) >- updateRMDSourceFromForm(); >- super.pageChange(newPageIndex); >+ for(int i=0;i<_pages.size();i++) >+ { >+ IPage page = (IPage) _pages.get(i); >+ page.pageChange(newPageIndex); >+ } >+ if (newPageIndex == _wsdlSourcePageIndex) >+ updateWSDLSourceFromForm(); >+ else if (newPageIndex == _xsdSourcePageIndex) >+ updateXSDSourceFromForm(); >+ else if (newPageIndex == _rmdSourcePageIndex) >+ updateRMDSourceFromForm(); >+ super.pageChange(newPageIndex); > } > > /** >@@ -538,9 +563,9 @@ > public void init(IEditorSite site, IEditorInput editorInput) > throws PartInitException > { >- super.init(site, editorInput); >- // Update titles. >- setPartName(editorInput.getName()); >+ super.init(site, editorInput); >+ // Update titles. >+ setPartName(editorInput.getName()); > } > > public boolean isReadOnly() >@@ -610,9 +635,9 @@ > } > > // Remove rmd file of capability >- if(_capabilityDomain.getMetaDataDescriptor()!=null) >+ if(_capabilityDomain.getCapability().getMetadata()!=null) > { >- PropertyMetaDataDescriptor metadataDescriptor = _capabilityDomain.getMetaDataDescriptor(); >+ MetadataDescriptor metadataDescriptor = _capabilityDomain.getCapability().getMetadata(); > if(metadataDescriptor.getDocumentRoot()!=null) > { > DocumentRoot rmdRoot = metadataDescriptor.getDocumentRoot(); >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/util/internal/MetaDataUtils.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.editor.capability/src/org/eclipse/tptp/wsdm/tooling/editor/capability/util/internal/MetaDataUtils.java,v >retrieving revision 1.5 >diff -u -r1.5 MetaDataUtils.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/capability/util/internal/MetaDataUtils.java 9 Jan 2007 19:51:45 -0000 1.5 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/util/internal/MetaDataUtils.java 20 Jan 2007 13:33:43 -0000 >@@ -24,19 +24,15 @@ > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IProgressMonitor; > import org.eclipse.emf.common.util.URI; >-import org.eclipse.emf.ecore.EStructuralFeature; > import org.eclipse.emf.ecore.impl.EStructuralFeatureImpl; > 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.emf.ecore.util.BasicExtendedMetaData; > import org.eclipse.emf.ecore.util.FeatureMap; > import org.eclipse.emf.ecore.xml.type.AnyType; >-import org.eclipse.emf.ecore.xml.type.internal.XMLDuration; > import org.eclipse.tptp.wsdm.tooling.editor.capability.internal.CapabilityDomain; >-import org.eclipse.tptp.wsdm.tooling.editor.capability.internal.FormMetric; > import org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability; >-import org.eclipse.tptp.wsdm.tooling.model.capabilities.Property; >+import org.eclipse.tptp.wsdm.tooling.model.capabilities.impl.MetadataDescriptor; > import org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.DefinitionsType; > import org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.DocumentRoot; > import org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.MetadataDescriptorFactory; >@@ -49,13 +45,11 @@ > import org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.ValidValuesType; > 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.model.muwsPart2.ChangeTypeType; >-import org.eclipse.tptp.wsdm.tooling.model.muwsPart2.GatheringTimeType; >-import org.eclipse.tptp.wsdm.tooling.model.muwsPart2.TimeScopeType; > import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.internal.Messages; > import org.eclipse.tptp.wsdm.tooling.util.internal.CapUtils; >+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.PropertyMetaDataDescriptor; >+import org.eclipse.tptp.wsdm.tooling.util.internal.RmdUtils; > import org.eclipse.tptp.wsdm.tooling.util.internal.WsdlUtils; > import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmConstants; > import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmToolingLog; >@@ -64,546 +58,436 @@ > > /** > * >- * Utility class to deal with metadata of Capability properties. >- * >+ * Utility class to deal with metadata of Capability properties. >+ * > */ > > public class MetaDataUtils > { > >- public static final String CONSTANT = "constant"; >+ public static final String CONSTANT = "constant"; > >- public static final String APPENDABLE = "appendable"; >+ public static final String APPENDABLE = "appendable"; > >- public static final String MUTABLE = "mutable"; >+ public static final String MUTABLE = "mutable"; > >- public static final String WRITABLE = "read-write"; >+ public static final String WRITABLE = "read-write"; > >- public static final String READ_ONLY = "read-only"; >- >- public static final String UNKNOWN = "unknown"; >- >- public static final String CHANGE_TYPE = "ChangeType"; >- >- public static final String TIME_SCOPE = "TimeScope"; >- >- public static final String GATHERING_TIME = "GatheringTime"; >- >- public static final String CALCULATION_INTERVAL = "CalculationInterval"; >- >- private static MetadataDescriptorFactory _rmdFactory = new MetadataDescriptorFactoryImpl(); >- >- /** >- * Returns the modifiability of given PropertyType. >- * >- * @param propertyMetaData >- * PropertyType metadata. >- * >- * @return the modifiability of given PropertyType metadata. >- */ >- public static String getModifiability(PropertyType propertyMetaData) >- { >- if (propertyMetaData == null) >- return UNKNOWN; >- if (propertyMetaData.getModifiability() == null) >- return UNKNOWN; >- return propertyMetaData.getModifiability().getLiteral(); >- } >- >- /** >- * Returns the mutability of given PropertyType. >- * >- * @param propertyMetaData >- * PropertyType metadata. >- * >- * @return the mutability of given PropertyType metadata. >- */ >- public static String getMutability(PropertyType propertyMetaData) >- { >- if (propertyMetaData == null) >- return UNKNOWN; >- if (propertyMetaData.getMutability() == null) >- return UNKNOWN; >- return propertyMetaData.getMutability().getLiteral(); >- } >- >- /** >- * Create new MetadataRoot object. >- * >- * @param targetNamespace >- * TargetNamespace to be used for new MetadataRoot object. >- * >- * @param descriptorName >- * Name to be used for MetadataDescriptorType. >- * >- * @return new MetadataRoot object. >- */ >- public static DocumentRoot createNewMetadataRoot(String targetNamespace, >- String descriptorName) >- { >- DocumentRoot dr = _rmdFactory.createDocumentRoot(); >- DefinitionsType def = _rmdFactory.createDefinitionsType(); >- dr.getXMLNSPrefixMap().put("muws-p1", WsdmConstants.MUWS_P1_NS); >- dr.getXMLNSPrefixMap().put("muws-p2", WsdmConstants.MUWS_P2_NS); >- dr.getXMLNSPrefixMap().put("tns", targetNamespace); >- def.setTargetNamespace(targetNamespace); >- MetadataDescriptorType mdtVal = _rmdFactory >- .createMetadataDescriptorType(); >- mdtVal.setName(descriptorName); >- def.getMetadataDescriptor().add(mdtVal); >- dr.setDefinitions(def); >- return dr; >- } >- >- /** >- * Returns the MetadataDescriptorType inside given MetadataRoot object. >- * >- * @param root >- * Given MetadataRoot object. >- * >- * @param name >- * Name of MetadataDescriptorType to be searched. >- * >- * @return the MetadataDescriptorType object. >- */ >- public static MetadataDescriptorType getMetadataDescriptorType( >- DocumentRoot root, String name) >- { >- List metaDescriptors = root.getDefinitions().getMetadataDescriptor(); >- for (int i = 0; i < metaDescriptors.size(); i++) >- { >- MetadataDescriptorType mdtVal = (MetadataDescriptorType) metaDescriptors >- .get(i); >- if (mdtVal.getName().equals(name)) >- return mdtVal; >- } >- return null; >- } >- >- /** >- * Returns ModifiabilityType based on parameter passed.<br> >- * Parameter should be one of the following<br><br> >- * >- * <b>MetaDataUtils.READ_ONLY</b><br> >- * <b>MetaDataUtils.WRITABLE</b><br> >- * >- */ >- public static ModifiabilityType getModifiabilityType(String modifiability) >- { >- if (modifiability.equals(READ_ONLY)) >- return ModifiabilityType.READ_ONLY_LITERAL; >- else if (modifiability.equals(WRITABLE)) >- return ModifiabilityType.READ_WRITE_LITERAL; >- return ModifiabilityType.READ_ONLY_LITERAL; >- } >- >- /** >- * Returns MutabilityType based on parameter passed.<br> >- * Parameter should be one of the following<br><br> >- * >- * <b>MetaDataUtils.CONSTANT</b><br> >- * <b>MetaDataUtils.MUTABLE</b><br> >- * <b>MetaDataUtils.APPENDABLE</b><br> >- */ >- public static MutabilityType getMutabilityType(String mutability) >- { >- if (mutability.equals(CONSTANT)) >- return MutabilityType.CONSTANT_LITERAL; >- else if (mutability.equals(MUTABLE)) >- return MutabilityType.MUTABLE_LITERAL; >- else if (mutability.equals(APPENDABLE)) >- return MutabilityType.APPENDABLE_LITERAL; >- return MutabilityType.MUTABLE_LITERAL; >- } >- >- /** >- * Returns ChangeTypeType based on parameter passed.<br> >- * Parameter should be one of the following<br><br> >- * >- * <b>"Counter"</b><br> >- * <b>"Gauge"</b><br> >- * <b>"Unknown"</b><br> >- */ >- public static ChangeTypeType getChangeTypeType(String changeType) >- { >- if(changeType.equals(ChangeTypeType.COUNTER_LITERAL.getLiteral())) >- return ChangeTypeType.COUNTER_LITERAL; >- else if(changeType.equals(ChangeTypeType.GAUGE_LITERAL.getLiteral())) >- return ChangeTypeType.GAUGE_LITERAL; >- return ChangeTypeType.UNKNOWN_LITERAL; >- } >- >- /** >- * Returns TimeScopeType based on parameter passed.<br> >- * Parameter should be one of the following<br><br> >- * >- * <b>"Interval"</b><br> >- * <b>"PointInTime"</b><br> >- * <b>"SinceReset"</b><br> >- */ >- public static TimeScopeType getTimeScopeType(String timeScope) >- { >- if(timeScope.equals(TimeScopeType.INTERVAL_LITERAL.getLiteral())) >- return TimeScopeType.INTERVAL_LITERAL; >- else if(timeScope.equals(TimeScopeType.POINT_IN_TIME_LITERAL.getLiteral())) >- return TimeScopeType.POINT_IN_TIME_LITERAL; >- return TimeScopeType.SINCE_RESET_LITERAL; >- } >- >- /** >- * Returns GatheringTimeType based on parameter passed.<br> >- * Parameter should be one of the following<br><br> >- * >- * <b>"OnChange"</b><br> >- * <b>"OnDemand"</b><br> >- * <b>"Periodic"</b><br> >- * <b>"Unknown"</b><br> >- */ >- public static GatheringTimeType getGatheringTimeType(String gatheringTime) >- { >- if(gatheringTime.equals(GatheringTimeType.ON_CHANGE_LITERAL.getLiteral())) >- return GatheringTimeType.ON_CHANGE_LITERAL; >- else if(gatheringTime.equals(GatheringTimeType.ON_DEMAND_LITERAL.getLiteral())) >- return GatheringTimeType.ON_DEMAND_LITERAL; >- else if(gatheringTime.equals(GatheringTimeType.PERIODIC_LITERAL.getLiteral())) >- return GatheringTimeType.PERIODIC_LITERAL; >- return GatheringTimeType.UNKNOWN_LITERAL; >- } >- >- /** >- * Saves an MetadataRoot object. into IFile in formatted representation. >- * >- * @param root >- * MetadataRoot object to be saved. >- * >- * @param rmdFile >- * Eclipse file to which MetadataRoot object will be saved. >- * >- * @param monitor >- * Progress monitor. >- */ >- public static void serializeAndFormat(DocumentRoot root, IFile rmdFile, >- IProgressMonitor monitor) >- { >- String fileURI = rmdFile.getFullPath().toString(); >- ByteArrayOutputStream baos = saveRMD(root, fileURI, null); >- String serializedString = CapUtils.getSerializedDocument(baos >- .toString()); >- ByteArrayInputStream baInputStream = new ByteArrayInputStream( >- serializedString.getBytes()); >- try >- { >- if (rmdFile.exists()) >- rmdFile.setContents(baInputStream, IFile.FORCE, monitor); >- else >- rmdFile.create(baInputStream, IFile.FORCE, monitor); >- } catch (CoreException e) >- { >- WsdmToolingLog.logError(Messages.FAILED_TO_SAVE_RMD_ERROR_, e); >- } >- } >- >- /** >- * Saves an MetadataRoot object into ResourceSet and returns the ByteArrayOutputStream of the saved object. >- * >- * @param root >- * MetadataRoot object to be saved. >- * >- * @param fileURI >- * URI String of the file to which MetadataRoot object will be saved. >- * >- * @param resourceSet >- * ResourceSet used for saving it, if null ResourceSet specified then the method >- * will create new ResourceSet. >- * >- * @return ByteArrayOutputStream representation of the saved object. >- */ >- public static ByteArrayOutputStream saveRMD(DocumentRoot root, >- String fileURI, ResourceSet resourceSet) >- { >- ByteArrayOutputStream baOutputStream = new ByteArrayOutputStream(); >- try >- { >- if (resourceSet == null) >- { >- resourceSet = new ResourceSetImpl(); >- } >- resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap() >- .put(Resource.Factory.Registry.DEFAULT_EXTENSION,new MyMetadataDescriptorResourceFactoryImpl()); >- URI uri = URI.createPlatformResourceURI(fileURI); >- Resource resource = resourceSet.createResource(uri); >- resource.getContents().add(root); >- >- // Save resource to the file system. >- Map options = new HashMap(); >- options.put(MetadataDescriptorResourceImpl.OPTION_LINE_WIDTH, new Integer(30)); >- resource.save(baOutputStream, options); >- } catch (Exception exception) >- { >- exception.printStackTrace(); >- WsdmToolingLog.logError(Messages.FAILED_TO_SAVE_RMD_ERROR_, exception); >- } >- return baOutputStream; >- } >- >- /** >- * Returns the EMF based MetadataRoot object of the given RMD file. >- * >- * @param file >- * Any RMD file available in eclipse workbench >- * >- * @return EMF based MetadataRoot object. >- */ >- public static DocumentRoot getDocumentRoot(IFile file) >- { >- URI rmdURI = URI.createPlatformResourceURI(file.getFullPath() >- .toString()); >- return getDocumentRoot(rmdURI); >- } >- >- /** >- * Returns the EMF based MetadataRoot object of the given URI of any RMD file. >- * >- * @param rmdURI >- * URI of any RMD file available in eclipse workbench >- * >- * @return EMF based MetadataRoot object. >- */ >- public static DocumentRoot getDocumentRoot(URI rmdURI) >- { >- DocumentRoot dr = null; >- ResourceSet resourceSet = new ResourceSetImpl(); >- >- resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap() >- .put(Resource.Factory.Registry.DEFAULT_EXTENSION, >- new MyMetadataDescriptorResourceFactoryImpl()); >- resourceSet.getPackageRegistry().put(MetadataDescriptorPackage.eNS_URI, >- MetadataDescriptorPackage.eINSTANCE); >- >- Resource resourceWsdl = null; >- try >- { >- resourceWsdl = resourceSet.getResource(rmdURI, true); >- } catch (Exception ex) >- { >- WsdmToolingLog.logError(Messages.FAILED_TO_LOAD_RMD_ERROR_, ex); >- return null; >- } >- List list = resourceWsdl.getContents(); >- >- for (int i = 0; i < list.size(); i++) >- { >- Object o = list.get(i); >- if (o instanceof DocumentRoot) >- { >- dr = (DocumentRoot) o; >- } >- } >- return dr; >- } >- >- /** >- * Returns the valid values of given ValidValuesType. >- * >- * @param validValuesType >- * ValidValuesType of property metadata. >- * >- * @return the valid values. >- */ >- public static Object[] getValidValues(ValidValuesType validValuesType) >- { >- List validValues = new LinkedList(); >- if (validValuesType == null) >- { >- return (Object[]) validValues.toArray(new Object[0]); >- } >- >- FeatureMap fm = validValuesType.getAny(); >- Iterator it = fm.iterator(); >- while (it.hasNext()) >- { >- Object obj = it.next(); >- if (obj instanceof EStructuralFeatureImpl.ContainmentUpdatingFeatureMapEntry) >- { >- EStructuralFeatureImpl.ContainmentUpdatingFeatureMapEntry entry = (EStructuralFeatureImpl.ContainmentUpdatingFeatureMapEntry) obj; >- AnyType value = (AnyType) entry.getValue(); >- FeatureMap mixedMap = value.getMixed(); >- Iterator mixedIt = mixedMap.iterator(); >- while (mixedIt.hasNext()) >- { >- EStructuralFeatureImpl.SimpleFeatureMapEntry simpleEntry = (EStructuralFeatureImpl.SimpleFeatureMapEntry) mixedIt >- .next(); >- validValues.add(simpleEntry.getValue()); >+ public static final String READ_ONLY = "read-only"; >+ >+ public static final String UNKNOWN = "unknown"; >+ >+ private static MetadataDescriptorFactory _rmdFactory = new MetadataDescriptorFactoryImpl(); >+ >+ /** >+ * Returns the modifiability of given PropertyType. >+ * >+ * @param propertyMetaData >+ * PropertyType metadata. >+ * >+ * @return the modifiability of given PropertyType metadata. >+ */ >+ public static String getModifiability(PropertyType propertyMetaData) >+ { >+ if (propertyMetaData == null) >+ return UNKNOWN; >+ if (propertyMetaData.getModifiability() == null) >+ return UNKNOWN; >+ return propertyMetaData.getModifiability().getLiteral(); >+ } >+ >+ /** >+ * Returns the mutability of given PropertyType. >+ * >+ * @param propertyMetaData >+ * PropertyType metadata. >+ * >+ * @return the mutability of given PropertyType metadata. >+ */ >+ public static String getMutability(PropertyType propertyMetaData) >+ { >+ if (propertyMetaData == null) >+ return UNKNOWN; >+ if (propertyMetaData.getMutability() == null) >+ return UNKNOWN; >+ return propertyMetaData.getMutability().getLiteral(); >+ } >+ >+ /** >+ * Create new MetadataRoot object. >+ * >+ * @param targetNamespace >+ * TargetNamespace to be used for new MetadataRoot object. >+ * >+ * @param descriptorName >+ * Name to be used for MetadataDescriptorType. >+ * >+ * @return new MetadataRoot object. >+ */ >+ public static DocumentRoot createNewMetadataRoot(String targetNamespace, >+ String descriptorName, String capabilityPortType, >+ String capabilityFileName) >+ { >+ DocumentRoot dr = _rmdFactory.createDocumentRoot(); >+ DefinitionsType def = _rmdFactory.createDefinitionsType(); >+ dr.getXMLNSPrefixMap().put("muws-p1", WsdmConstants.MUWS_P1_NS); >+ dr.getXMLNSPrefixMap().put("muws-p2", WsdmConstants.MUWS_P2_NS); >+ dr.getXMLNSPrefixMap().put("tns", targetNamespace); >+ def.setTargetNamespace(targetNamespace); >+ MetadataDescriptorType mdtVal = _rmdFactory >+ .createMetadataDescriptorType(); >+ mdtVal.setName(descriptorName); >+ mdtVal.setInterface("tns:" + capabilityPortType); >+ mdtVal.setWsdlLocation(targetNamespace + " " + capabilityFileName); >+ def.getMetadataDescriptor().add(mdtVal); >+ dr.setDefinitions(def); >+ return dr; >+ } >+ >+ /** >+ * Returns the MetadataDescriptorType inside given MetadataRoot object. >+ * >+ * @param root >+ * Given MetadataRoot object. >+ * >+ * @param name >+ * Name of MetadataDescriptorType to be searched. >+ * >+ * @return the MetadataDescriptorType object. >+ */ >+ public static MetadataDescriptorType getMetadataDescriptorType( >+ DocumentRoot root, String name) >+ { >+ List metaDescriptors = root.getDefinitions().getMetadataDescriptor(); >+ for (int i = 0; i < metaDescriptors.size(); i++) >+ { >+ MetadataDescriptorType mdtVal = (MetadataDescriptorType) metaDescriptors >+ .get(i); >+ if (mdtVal.getName().equals(name)) >+ return mdtVal; > } >- } >+ return null; > } >- return (Object[]) validValues.toArray(new Object[0]); >- } > >- /** >- * Returns the static values of given StaticValuesType. >- * >- * @param staticValuesType >- * StaticValuesType of property metadata. >- * >- * @return the static values. >- */ >- public static Object[] getStaticValues(StaticValuesType staticValuesType) >- { >- List staticValues = new LinkedList(); >- if (staticValuesType == null) >- { >- return (Object[]) staticValues.toArray(new Object[0]); >- } >- >- FeatureMap fm = staticValuesType.getAny(); >- Iterator it = fm.iterator(); >- while (it.hasNext()) >- { >- Object obj = it.next(); >- if (obj instanceof EStructuralFeatureImpl.ContainmentUpdatingFeatureMapEntry) >- { >- EStructuralFeatureImpl.ContainmentUpdatingFeatureMapEntry entry = (EStructuralFeatureImpl.ContainmentUpdatingFeatureMapEntry) obj; >- AnyType value = (AnyType) entry.getValue(); >- FeatureMap mixedMap = value.getMixed(); >- Iterator mixedIt = mixedMap.iterator(); >- while (mixedIt.hasNext()) >- { >- EStructuralFeatureImpl.SimpleFeatureMapEntry simpleEntry = (EStructuralFeatureImpl.SimpleFeatureMapEntry) mixedIt >- .next(); >- staticValues.add(simpleEntry.getValue()); >+ /** >+ * Returns ModifiabilityType based on parameter passed.<br> >+ * Parameter should be one of the following<br> >+ * <br> >+ * >+ * <b>MetaDataUtils.READ_ONLY</b><br> >+ * <b>MetaDataUtils.WRITABLE</b><br> >+ * >+ */ >+ public static ModifiabilityType getModifiabilityType(String modifiability) >+ { >+ if (modifiability.equals(READ_ONLY)) >+ return ModifiabilityType.READ_ONLY_LITERAL; >+ else if (modifiability.equals(WRITABLE)) >+ return ModifiabilityType.READ_WRITE_LITERAL; >+ return ModifiabilityType.READ_ONLY_LITERAL; >+ } >+ >+ /** >+ * Returns MutabilityType based on parameter passed.<br> >+ * Parameter should be one of the following<br> >+ * <br> >+ * >+ * <b>MetaDataUtils.CONSTANT</b><br> >+ * <b>MetaDataUtils.MUTABLE</b><br> >+ * <b>MetaDataUtils.APPENDABLE</b><br> >+ */ >+ public static MutabilityType getMutabilityType(String mutability) >+ { >+ if (mutability.equals(CONSTANT)) >+ return MutabilityType.CONSTANT_LITERAL; >+ else if (mutability.equals(MUTABLE)) >+ return MutabilityType.MUTABLE_LITERAL; >+ else if (mutability.equals(APPENDABLE)) >+ return MutabilityType.APPENDABLE_LITERAL; >+ return MutabilityType.MUTABLE_LITERAL; >+ } >+ >+ /** >+ * Saves an MetadataRoot object. into IFile in formatted representation. >+ * >+ * @param root >+ * MetadataRoot object to be saved. >+ * >+ * @param rmdFile >+ * Eclipse file to which MetadataRoot object will be saved. >+ * >+ * @param monitor >+ * Progress monitor. >+ */ >+ public static void serializeAndFormat(DocumentRoot root, IFile rmdFile, >+ IProgressMonitor monitor) >+ { >+ String fileURI = rmdFile.getFullPath().toString(); >+ ByteArrayOutputStream baos = saveRMD(root, fileURI, null); >+ String serializedString = CapUtils.getSerializedDocument(baos >+ .toString()); >+ ByteArrayInputStream baInputStream = new ByteArrayInputStream( >+ serializedString.getBytes()); >+ try >+ { >+ if (rmdFile.exists()) >+ rmdFile.setContents(baInputStream, IFile.FORCE, monitor); >+ else >+ rmdFile.create(baInputStream, IFile.FORCE, monitor); >+ } catch (CoreException e) >+ { >+ WsdmToolingLog.logError(Messages.FAILED_TO_SAVE_RMD_ERROR_, e); > } >- } > } >- return (Object[]) staticValues.toArray(new Object[0]); >- } > >- /** >- * Returns FormMetric of given property metadata. >- */ >- public static FormMetric getMetric(CapabilityDomain capabilityDomain, >- Property _property) >- { >- FormMetric metric = new FormMetric(capabilityDomain, _property); >- if (_property.getMetaData() == null) >- return metric; >- FeatureMap fm = _property.getMetaData().getAny(); >- Iterator it = fm.iterator(); >- while (it.hasNext()) >- { >- Object obj = it.next(); >- if (obj instanceof EStructuralFeatureImpl.SimpleFeatureMapEntry) >- { >- EStructuralFeatureImpl.SimpleFeatureMapEntry entry = (EStructuralFeatureImpl.SimpleFeatureMapEntry) obj; >- if(entry.getValue() instanceof ChangeTypeType) >+ /** >+ * Saves an MetadataRoot object into ResourceSet and returns the >+ * ByteArrayOutputStream of the saved object. >+ * >+ * @param root >+ * MetadataRoot object to be saved. >+ * >+ * @param fileURI >+ * URI String of the file to which MetadataRoot object will be >+ * saved. >+ * >+ * @param resourceSet >+ * ResourceSet used for saving it, if null ResourceSet specified >+ * then the method will create new ResourceSet. >+ * >+ * @return ByteArrayOutputStream representation of the saved object. >+ */ >+ public static ByteArrayOutputStream saveRMD(DocumentRoot root, >+ String fileURI, ResourceSet resourceSet) >+ { >+ ByteArrayOutputStream baOutputStream = new ByteArrayOutputStream(); >+ try > { >- ChangeTypeType changeType = (ChangeTypeType)entry.getValue(); >- metric.setChangeType(changeType); >- } >- if(entry.getValue() instanceof TimeScopeType) >+ if (resourceSet == null) >+ { >+ resourceSet = new ResourceSetImpl(); >+ } >+ resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap() >+ .put(Resource.Factory.Registry.DEFAULT_EXTENSION, >+ new MyMetadataDescriptorResourceFactoryImpl()); >+ URI uri = URI.createPlatformResourceURI(fileURI); >+ Resource resource = resourceSet.createResource(uri); >+ resource.getContents().add(root); >+ >+ // Save resource to the file system. >+ Map options = new HashMap(); >+ options.put(MetadataDescriptorResourceImpl.OPTION_LINE_WIDTH, >+ new Integer(30)); >+ resource.save(baOutputStream, options); >+ } catch (Exception exception) > { >- TimeScopeType timeScope = (TimeScopeType)entry.getValue(); >- metric.setTimeScope(timeScope); >+ exception.printStackTrace(); >+ WsdmToolingLog.logError(Messages.FAILED_TO_SAVE_RMD_ERROR_, >+ exception); > } >- if(entry.getValue() instanceof GatheringTimeType) >+ return baOutputStream; >+ } >+ >+ /** >+ * Returns the EMF based MetadataRoot object of the given RMD file. >+ * >+ * @param file >+ * Any RMD file available in eclipse workbench >+ * >+ * @return EMF based MetadataRoot object. >+ */ >+ public static DocumentRoot getDocumentRoot(IFile file) >+ { >+ URI rmdURI = URI.createPlatformResourceURI(file.getFullPath() >+ .toString()); >+ return getDocumentRoot(rmdURI); >+ } >+ >+ /** >+ * Returns the EMF based MetadataRoot object of the given URI of any RMD >+ * file. >+ * >+ * @param rmdURI >+ * URI of any RMD file available in eclipse workbench >+ * >+ * @return EMF based MetadataRoot object. >+ */ >+ public static DocumentRoot getDocumentRoot(URI rmdURI) >+ { >+ DocumentRoot dr = null; >+ ResourceSet resourceSet = new ResourceSetImpl(); >+ >+ resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap() >+ .put(Resource.Factory.Registry.DEFAULT_EXTENSION, >+ new MyMetadataDescriptorResourceFactoryImpl()); >+ resourceSet.getPackageRegistry().put(MetadataDescriptorPackage.eNS_URI, >+ MetadataDescriptorPackage.eINSTANCE); >+ >+ Resource resourceWsdl = null; >+ try >+ { >+ resourceWsdl = resourceSet.getResource(rmdURI, true); >+ } catch (Exception ex) > { >- GatheringTimeType gatheringTime = (GatheringTimeType)entry.getValue(); >- metric.setGatheringTime(gatheringTime); >+ WsdmToolingLog.logError(Messages.FAILED_TO_LOAD_RMD_ERROR_, ex); >+ return null; > } >- if(entry.getValue() instanceof XMLDuration) >+ List list = resourceWsdl.getContents(); >+ >+ for (int i = 0; i < list.size(); i++) > { >- XMLDuration calculationInterval = (XMLDuration)entry.getValue(); >- metric.setCalculationInterval(calculationInterval); >+ Object o = list.get(i); >+ if (o instanceof DocumentRoot) >+ { >+ dr = (DocumentRoot) o; >+ } > } >- } >+ return dr; > } >- return metric; >- } > >- private static boolean isKindOf(EStructuralFeature esf, String kind) >- { >- BasicExtendedMetaData.EStructuralFeatureExtendedMetaData emd = ((EStructuralFeatureImpl) esf) >- .getExtendedMetaData(); >- return emd.getNamespace().equals(WsdmConstants.MUWS_P2_NS) >- && emd.getName().equals(kind); >- } >- >- /** >- * Returns true if the property metadata has Metrics defined for it. >- * >- * @param metadata >- * PropertyType metadata. >- * >- * @return true if the property metadata has Metrics defined for it. >- */ >- public static boolean hasMetricsCapability(PropertyType metadata) >- { >- FeatureMap fm = metadata.getAny(); >- Iterator it = fm.iterator(); >- while (it.hasNext()) >- { >- Object obj = it.next(); >- if (obj instanceof EStructuralFeatureImpl.SimpleFeatureMapEntry) >- { >- EStructuralFeatureImpl.SimpleFeatureMapEntry entry = (EStructuralFeatureImpl.SimpleFeatureMapEntry) obj; >- EStructuralFeature esf = entry.getEStructuralFeature(); >- if (isKindOf(esf, "Capability")) >- { >- if(entry.getValue() instanceof String) >- if(entry.getValue().equals(WsdmConstants.MUWS_METRICS_NS)) >- return true; >+ /** >+ * Returns the valid values of given ValidValuesType. >+ * >+ * @param validValuesType >+ * ValidValuesType of property metadata. >+ * >+ * @return the valid values. >+ */ >+ public static Object[] getValidValues(ValidValuesType validValuesType) >+ { >+ List validValues = new LinkedList(); >+ if (validValuesType == null) >+ { >+ return (Object[]) validValues.toArray(new Object[0]); >+ } >+ >+ FeatureMap fm = validValuesType.getAny(); >+ Iterator it = fm.iterator(); >+ while (it.hasNext()) >+ { >+ Object obj = it.next(); >+ if (obj instanceof EStructuralFeatureImpl.ContainmentUpdatingFeatureMapEntry) >+ { >+ EStructuralFeatureImpl.ContainmentUpdatingFeatureMapEntry entry = (EStructuralFeatureImpl.ContainmentUpdatingFeatureMapEntry) obj; >+ AnyType value = (AnyType) entry.getValue(); >+ FeatureMap mixedMap = value.getMixed(); >+ Iterator mixedIt = mixedMap.iterator(); >+ while (mixedIt.hasNext()) >+ { >+ EStructuralFeatureImpl.SimpleFeatureMapEntry simpleEntry = (EStructuralFeatureImpl.SimpleFeatureMapEntry) mixedIt >+ .next(); >+ validValues.add(simpleEntry.getValue()); >+ } >+ } > } >- } >+ return (Object[]) validValues.toArray(new Object[0]); > } >- return false; >- } > >- /** >- * This method is used to create new PropertyMetaDataDescriptor. >- * PropertyMetaDataDescriptor is a wrapper class for an RMD representation. >- * This method will be called from different pieces of capability editor, >- * when there is no metadata defined for any property. So If some one has property >- * defined for capability but no metadata defined for it, this method will be used to create >- * new PropertyMetaDataDescriptor for CapabilityDomain. >- * >- * @param capabilityDomain >- * Capability editor based CapabilityDomain. >- * >- * @return new PropertyMetaDataDescriptor created. >- */ >- public static PropertyMetaDataDescriptor createMetaDataDescriptor( >- CapabilityDomain capabilityDomain) >- { >- Capability capability = capabilityDomain.getCapability(); >- >- String targetNamespace = capabilityDomain.getDefinition() >- .getTargetNamespace(); >- if (capabilityDomain.getPropertySchema() != null) >- targetNamespace = capabilityDomain.getPropertySchema() >- .getTargetNamespace(); >- >- String descriptorName = capability.getName() + "Descriptor"; >- DocumentRoot root = MetaDataUtils.createNewMetadataRoot( >- targetNamespace, descriptorName); >- MetadataDescriptorType mdtVal = MetaDataUtils >- .getMetadataDescriptorType(root, descriptorName); >- PropertyMetaDataDescriptor metaDataDescriptor = new PropertyMetaDataDescriptor( >- root, capability, descriptorName); >- metaDataDescriptor.setDocumentRoot(root); >- metaDataDescriptor.setMetadataDescriptorType(mdtVal); >- capabilityDomain.setMetaDataDescriptor(metaDataDescriptor); >- >- Definition definition = capabilityDomain.getDefinition(); >- String wsrmdPrefix = WsdlUtils.createOrFindPrefix(definition, >- WsdmConstants.WSRMD_NS, "wsrmd"); >- PortType pt = WsdlUtils.getPortType(definition); >- pt.getElement().setAttributeNS(WsdmConstants.WSRMD_NS, >- wsrmdPrefix + ":" + WsdlUtils.METADATA_DESCRIPTOR_KEY, >- descriptorName); >- pt.getElement().setAttributeNS(WsdmConstants.WSRMD_NS, >- wsrmdPrefix + ":" + WsdlUtils.METADATA_DESCRIPTOR_LOCATION_KEY, >- capability.getName() + ".rmd"); >+ /** >+ * Returns the static values of given StaticValuesType. >+ * >+ * @param staticValuesType >+ * StaticValuesType of property metadata. >+ * >+ * @return the static values. >+ */ >+ public static Object[] getStaticValues(StaticValuesType staticValuesType) >+ { >+ List staticValues = new LinkedList(); >+ if (staticValuesType == null) >+ { >+ return (Object[]) staticValues.toArray(new Object[0]); >+ } >+ >+ FeatureMap fm = staticValuesType.getAny(); >+ Iterator it = fm.iterator(); >+ while (it.hasNext()) >+ { >+ Object obj = it.next(); >+ if (obj instanceof EStructuralFeatureImpl.ContainmentUpdatingFeatureMapEntry) >+ { >+ EStructuralFeatureImpl.ContainmentUpdatingFeatureMapEntry entry = (EStructuralFeatureImpl.ContainmentUpdatingFeatureMapEntry) obj; >+ AnyType value = (AnyType) entry.getValue(); >+ FeatureMap mixedMap = value.getMixed(); >+ Iterator mixedIt = mixedMap.iterator(); >+ while (mixedIt.hasNext()) >+ { >+ EStructuralFeatureImpl.SimpleFeatureMapEntry simpleEntry = (EStructuralFeatureImpl.SimpleFeatureMapEntry) mixedIt >+ .next(); >+ staticValues.add(simpleEntry.getValue()); >+ } >+ } >+ } >+ return (Object[]) staticValues.toArray(new Object[0]); >+ } > >- return metaDataDescriptor; >- } >+ /** >+ * This method is used to create new PropertyMetaDataDescriptor. >+ * PropertyMetaDataDescriptor is a wrapper class for an RMD representation. >+ * This method will be called from different pieces of capability editor, >+ * when there is no metadata defined for any property. So If some one has >+ * property defined for capability but no metadata defined for it, this >+ * method will be used to create new PropertyMetaDataDescriptor for >+ * CapabilityDomain. >+ * >+ * @param capabilityDomain >+ * Capability editor based CapabilityDomain. >+ * >+ * @return new PropertyMetaDataDescriptor created. >+ */ >+ public static MetadataDescriptor createMetaDataDescriptor( >+ CapabilityDomain capabilityDomain) >+ { >+ Capability capability = capabilityDomain.getCapability(); >+ >+ String targetNamespace = capability.getDefinition() >+ .getTargetNamespace(); >+ if (capabilityDomain.getPropertySchema() != null) >+ targetNamespace = capabilityDomain.getPropertySchema() >+ .getTargetNamespace(); >+ >+ String descriptorName = capability.getName() + "Descriptor"; >+ String capabilityPortType = WsdlUtils.getPortType( >+ capability.getDefinition()).getQName().getLocalPart(); >+ String capabilityFileName = capabilityDomain.getCapabilityIFile() >+ .getName(); >+ DocumentRoot root = MetaDataUtils.createNewMetadataRoot( >+ targetNamespace, descriptorName, capabilityPortType, >+ capabilityFileName); >+ MetadataDescriptorType mdtVal = MetaDataUtils >+ .getMetadataDescriptorType(root, descriptorName); >+ MetadataDescriptor metaDataDescriptor = new MetadataDescriptor( >+ capability, root, descriptorName); >+ metaDataDescriptor.setDocumentRoot(root); >+ metaDataDescriptor.setMetadataDescriptorType(mdtVal); >+ >+ Definition definition = capability.getDefinition(); >+ String wsrmdPrefix = WsdlUtils.createOrFindPrefix(definition, >+ WsdmConstants.WSRMD_NS, "wsrmd"); >+ PortType pt = WsdlUtils.getPortType(definition); >+ pt.getElement().setAttributeNS(WsdmConstants.WSRMD_NS, >+ wsrmdPrefix + ":" + WsdlUtils.METADATA_DESCRIPTOR_KEY, >+ descriptorName); >+ pt.getElement().setAttributeNS(WsdmConstants.WSRMD_NS, >+ wsrmdPrefix + ":" + WsdlUtils.METADATA_DESCRIPTOR_LOCATION_KEY, >+ capability.getName() + ".rmd"); >+ >+ return metaDataDescriptor; >+ } >+ >+ public static void save(MetadataDescriptor metadataDescriptor, >+ IProgressMonitor monitor) >+ { >+ DocumentRoot _root = metadataDescriptor.getDocumentRoot(); >+ String rmdFileUri = _root.eResource().getURI().toString(); >+ IFile rmdFile = null; >+ try >+ { >+ rmdFile = EclipseUtils.getIFile(rmdFileUri); >+ } catch (CoreException e) >+ { >+ e.printStackTrace(); >+ } >+ RmdUtils.serializeAndFormat(_root, rmdFile, monitor); >+ } > } >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/property/internal/ChangePropertyNameMetaDataCommand.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.editor.capability/src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/property/internal/ChangePropertyNameMetaDataCommand.java,v >retrieving revision 1.3 >diff -u -r1.3 ChangePropertyNameMetaDataCommand.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/property/internal/ChangePropertyNameMetaDataCommand.java 9 Jan 2007 19:51:43 -0000 1.3 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/property/internal/ChangePropertyNameMetaDataCommand.java 20 Jan 2007 13:33:31 -0000 >@@ -12,10 +12,9 @@ > > package org.eclipse.tptp.wsdm.tooling.editor.capability.command.property.internal; > >-import org.eclipse.emf.ecore.xml.type.internal.QName; > 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.util.internal.PropertyMetaDataDescriptor; >+import org.eclipse.tptp.wsdm.tooling.model.capabilities.impl.MetadataDescriptor; > > /** > * Command class to change the name of a property inside RMD.<br> >@@ -34,8 +33,8 @@ > public ChangePropertyNameMetaDataCommand(CapabilityDomain capabilityDomain, > Property property, String newName) > { >- super(capabilityDomain, property); >- _newName = newName; >+ super(capabilityDomain, property); >+ _newName = newName; > } > > /** >@@ -43,15 +42,14 @@ > */ > public void execute() > { >- PropertyMetaDataDescriptor metaDataDescriptor = _capabilityDomain >- .getMetaDataDescriptor(); >- if (metaDataDescriptor == null) >- return; >- if (_metadata == null) >- return; >- String ns = _property.getElement().getTargetNamespace(); >- String prefix = metaDataDescriptor.getPrefix(ns); >- _metadata.setName(new QName(ns, _newName, prefix)); >+ MetadataDescriptor metaDataDescriptor = _capabilityDomain.getCapability().getMetadata(); >+ if (metaDataDescriptor == null) >+ return; >+ if (_metadata == null) >+ return; >+ String ns = _property.getElement().getTargetNamespace(); >+ String prefix = metaDataDescriptor.getPrefix(ns); >+ _metadata.setName(prefix+":"+_newName); > } > > } >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/property/internal/RemovePropertyCommand.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.editor.capability/src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/property/internal/RemovePropertyCommand.java,v >retrieving revision 1.3 >diff -u -r1.3 RemovePropertyCommand.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/property/internal/RemovePropertyCommand.java 9 Jan 2007 19:51:43 -0000 1.3 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/property/internal/RemovePropertyCommand.java 20 Jan 2007 13:33:32 -0000 >@@ -15,8 +15,8 @@ > import org.eclipse.tptp.wsdm.tooling.editor.capability.internal.CapabilityDomain; > import org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability; > import org.eclipse.tptp.wsdm.tooling.model.capabilities.Property; >+import org.eclipse.tptp.wsdm.tooling.model.capabilities.impl.MetadataDescriptor; > import org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.PropertyType; >-import org.eclipse.tptp.wsdm.tooling.util.internal.PropertyMetaDataDescriptor; > import org.eclipse.tptp.wsdm.tooling.util.internal.XsdUtils; > import org.eclipse.xsd.XSDComplexTypeDefinition; > import org.eclipse.xsd.XSDElementDeclaration; >@@ -52,11 +52,11 @@ > public RemovePropertyCommand(CapabilityDomain capabilityDomain, > Property property) > { >- _capabilityDomain = capabilityDomain; >- _resourcePropertyElement = capabilityDomain >- .getResourcePropertyElement(); >- _property = property; >- _element = property.getElement(); >+ _capabilityDomain = capabilityDomain; >+ _resourcePropertyElement = capabilityDomain >+ .getResourcePropertyElement(); >+ _property = property; >+ _element = property.getElement(); > } > > /** >@@ -64,61 +64,60 @@ > */ > public void execute() > { >- removeFromResourcePropertyElement(); >- removeFromSchema(); >- removeMetadata(); >- removeFromCapability(); >+ removeFromResourcePropertyElement(); >+ removeFromSchema(); >+ removeMetadata(); >+ removeFromCapability(); > } > > private void removeFromResourcePropertyElement() > { >- XSDComplexTypeDefinition typeDef = (XSDComplexTypeDefinition) _resourcePropertyElement >- .getAnonymousTypeDefinition(); >- XSDModelGroup modelGroup = XsdUtils.getXSDModelGroup(typeDef); >- XSDElementDeclaration[] elementRefs = XsdUtils >- .getElementDeclarations(modelGroup); >- for (int i = 0; i < elementRefs.length; i++) >- { >- if (XsdUtils.isReferencedElement(elementRefs[i])) >- { >- XSDElementDeclaration schemaElement = elementRefs[i] >- .getResolvedElementDeclaration(); >- if (schemaElement.getName().equals(_element.getName()) >- && schemaElement.getTargetNamespace().equals( >- _element.getTargetNamespace())) >+ XSDComplexTypeDefinition typeDef = (XSDComplexTypeDefinition) _resourcePropertyElement >+ .getAnonymousTypeDefinition(); >+ XSDModelGroup modelGroup = XsdUtils.getXSDModelGroup(typeDef); >+ XSDElementDeclaration[] elementRefs = XsdUtils >+ .getElementDeclarations(modelGroup); >+ for (int i = 0; i < elementRefs.length; i++) > { >- XsdUtils.removeElementDeclaration(modelGroup, >- elementRefs[i]); >- if (elementRefs.length == 1) >- _resourcePropertyElement >- .setAnonymousTypeDefinition(null); >+ if (XsdUtils.isReferencedElement(elementRefs[i])) >+ { >+ XSDElementDeclaration schemaElement = elementRefs[i] >+ .getResolvedElementDeclaration(); >+ if (schemaElement.getName().equals(_element.getName()) >+ && schemaElement.getTargetNamespace().equals( >+ _element.getTargetNamespace())) >+ { >+ XsdUtils.removeElementDeclaration(modelGroup, >+ elementRefs[i]); >+ if (elementRefs.length == 1) >+ _resourcePropertyElement >+ .setAnonymousTypeDefinition(null); >+ } >+ } > } >- } >- } > > } > > private void removeFromSchema() > { >- _element.getSchema().getContents().remove(_element); >+ _element.getSchema().getContents().remove(_element); > } > > private void removeFromCapability() > { >- Capability capability = _capabilityDomain.getCapability(); >- capability.getProperties().remove(_property); >+ Capability capability = _capabilityDomain.getCapability(); >+ capability.getProperties().remove(_property); > } > > private void removeMetadata() > { >- PropertyMetaDataDescriptor metaDataDescriptor = _capabilityDomain >- .getMetaDataDescriptor(); >- if (metaDataDescriptor == null) >- return; >- PropertyType metadata = _property.getMetaData(); >- if (metadata == null) >- return; >- metaDataDescriptor.getMetadataDescriptorType().getProperty().remove( >- metadata); >+ MetadataDescriptor metaDataDescriptor = _capabilityDomain.getCapability().getMetadata(); >+ if (metaDataDescriptor == null) >+ return; >+ PropertyType metadata = _property.getMetaData(); >+ if (metadata == null) >+ return; >+ metaDataDescriptor.getMetadataDescriptorType().getProperty().remove( >+ metadata); > } > } >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/property/internal/AddPropertyCommand.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.editor.capability/src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/property/internal/AddPropertyCommand.java,v >retrieving revision 1.3 >diff -u -r1.3 AddPropertyCommand.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/property/internal/AddPropertyCommand.java 9 Jan 2007 19:51:43 -0000 1.3 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/property/internal/AddPropertyCommand.java 20 Jan 2007 13:33:31 -0000 >@@ -63,11 +63,11 @@ > public AddPropertyCommand(CapabilityDomain capabilityDomain, > XSDElementDeclaration newProperty) > { >- _capabilityDomain = capabilityDomain; >- _newProperty = newProperty; >- _resourcePropertyElement = _capabilityDomain >- .getResourcePropertyElement(); >- _propertySchema = _capabilityDomain.getPropertySchema(); >+ _capabilityDomain = capabilityDomain; >+ _newProperty = newProperty; >+ _resourcePropertyElement = _capabilityDomain >+ .getResourcePropertyElement(); >+ _propertySchema = _capabilityDomain.getPropertySchema(); > } > > /** >@@ -75,126 +75,126 @@ > */ > public void execute() > { >- addPropertyToSchema(); >- addPropertyToResourceElement(); >- addPropertyToCapability(); >+ addPropertyToSchema(); >+ addPropertyToResourceElement(); >+ addPropertyToCapability(); > } > > private void addPropertyToSchema() > { >- _propertySchema.getContents().add(_newProperty); >+ _propertySchema.getContents().add(_newProperty); > } > > private void addPropertyToResourceElement() > { > >- if (_resourcePropertyElement == null) >- { >- // No Resource property element is defined for the capability >- // So create new XSD Include and create new Resource property element >- createNewResourcePropertyElement(); >- } >- >- XSDModelGroup modelGroup = getXSDModelGroup(); >- XSDElementDeclaration propertyRef = XSDFactory.eINSTANCE >- .createXSDElementDeclaration(); >- propertyRef.setResolvedElementDeclaration(_newProperty); >- XSDParticle simpleElementParticle = XSDFactory.eINSTANCE >- .createXSDParticle(); >- simpleElementParticle.setContent(propertyRef); >- modelGroup.getContents().add(simpleElementParticle); >+ if (_resourcePropertyElement == null) >+ { >+ // No Resource property element is defined for the capability >+ // So create new XSD Include and create new Resource property element >+ createNewResourcePropertyElement(); >+ } >+ >+ XSDModelGroup modelGroup = getXSDModelGroup(); >+ XSDElementDeclaration propertyRef = XSDFactory.eINSTANCE >+ .createXSDElementDeclaration(); >+ propertyRef.setResolvedElementDeclaration(_newProperty); >+ XSDParticle simpleElementParticle = XSDFactory.eINSTANCE >+ .createXSDParticle(); >+ simpleElementParticle.setContent(propertyRef); >+ modelGroup.getContents().add(simpleElementParticle); > } > > private void createNewResourcePropertyElement() > { >- Definition definition = _capabilityDomain.getDefinition(); >- >- String tns = _capabilityDomain.getDefinition().getTargetNamespace(); >- String rpElementName = _capabilityDomain.getCapability().getName() >- + "Properties"; >- XSDSchema wsdlSchema = WsdlUtils.createOrFindSchema( >- _capabilityDomain.getDefinition(), tns); >- >- // create new XSD Include >- createPropXSDInclude(wsdlSchema); >- >- // create new Resource property element >- _resourcePropertyElement = XSDFactory.eINSTANCE >- .createXSDElementDeclaration(); >- wsdlSchema.getContents().add(_resourcePropertyElement); >- _resourcePropertyElement.setName(rpElementName); >- _resourcePropertyElement.setAnonymousTypeDefinition(null); >- _capabilityDomain >- .setResourcePropertyElement(_resourcePropertyElement); >- >- String wsrpPrefix = WsdlUtils.createOrFindPrefix(definition, >- WsdmConstants.WSRP_NS, "wsrp"); >- PortType pt = WsdlUtils.getPortType(definition); >- String rpElementPrefix = WsdlUtils.getPrefix(definition, wsdlSchema >- .getTargetNamespace()); >- pt.getElement().setAttributeNS( >- WsdmConstants.WSRP_NS, >- wsrpPrefix + ":" >- + WsdlUtils.RESOURCE_PROPERTIES_ELEMENT_KEY, >- rpElementPrefix + ":" + rpElementName); >+ Definition definition = _capabilityDomain.getCapability().getDefinition(); >+ >+ String tns = _capabilityDomain.getCapability().getDefinition().getTargetNamespace(); >+ String rpElementName = _capabilityDomain.getCapability().getName() >+ + "Properties"; >+ XSDSchema wsdlSchema = WsdlUtils.createOrFindSchema( >+ _capabilityDomain.getCapability().getDefinition(), tns); >+ >+ // create new XSD Include >+ createPropXSDInclude(wsdlSchema); >+ >+ // create new Resource property element >+ _resourcePropertyElement = XSDFactory.eINSTANCE >+ .createXSDElementDeclaration(); >+ wsdlSchema.getContents().add(_resourcePropertyElement); >+ _resourcePropertyElement.setName(rpElementName); >+ _resourcePropertyElement.setAnonymousTypeDefinition(null); >+ _capabilityDomain >+ .setResourcePropertyElement(_resourcePropertyElement); >+ >+ String wsrpPrefix = WsdlUtils.createOrFindPrefix(definition, >+ WsdmConstants.WSRP_NS, "wsrp"); >+ PortType pt = WsdlUtils.getPortType(definition); >+ String rpElementPrefix = WsdlUtils.getPrefix(definition, wsdlSchema >+ .getTargetNamespace()); >+ pt.getElement().setAttributeNS( >+ WsdmConstants.WSRP_NS, >+ wsrpPrefix + ":" >+ + WsdlUtils.RESOURCE_PROPERTIES_ELEMENT_KEY, >+ rpElementPrefix + ":" + rpElementName); > } > > private void createPropXSDInclude(XSDSchema schema) > { >- String schemaLocation = _newProperty.getSchema().getSchemaLocation(); >- int index = schemaLocation.lastIndexOf('/') + 1; >- String xsdFileName = schemaLocation.substring(index); >- XSDInclude include = XSDFactory.eINSTANCE.createXSDInclude(); >- include.setSchemaLocation(xsdFileName); >- schema.getContents().add(include); >+ String schemaLocation = _newProperty.getSchema().getSchemaLocation(); >+ int index = schemaLocation.lastIndexOf('/') + 1; >+ String xsdFileName = schemaLocation.substring(index); >+ XSDInclude include = XSDFactory.eINSTANCE.createXSDInclude(); >+ include.setSchemaLocation(xsdFileName); >+ schema.getContents().add(include); > } > > private void addPropertyToCapability() > { >- _property = CapabilitiesFactory.eINSTANCE.createProperty(); >- _property.setElement(_newProperty); >- Capability capability = _capabilityDomain.getCapability(); >- capability.getProperties().add(_property); >+ _property = CapabilitiesFactory.eINSTANCE.createProperty(); >+ _property.setElement(_newProperty); >+ Capability capability = _capabilityDomain.getCapability(); >+ capability.getProperties().add(_property); > } > > private boolean isResourcePropertyElementEmpty() > { >- if (_resourcePropertyElement.getAnonymousTypeDefinition() == null) >- return true; >- return false; >+ if (_resourcePropertyElement.getAnonymousTypeDefinition() == null) >+ return true; >+ return false; > } > > private XSDModelGroup getXSDModelGroup() > { >- XSDModelGroup modelGroup = null; >- if (isResourcePropertyElementEmpty()) >- { >- modelGroup = createNewXSDModelGroup(); >- } >- else >- { >- XSDComplexTypeDefinition typeDef = (XSDComplexTypeDefinition) _resourcePropertyElement >- .getAnonymousTypeDefinition(); >- modelGroup = XsdUtils.getXSDModelGroup(typeDef); >- } >- return modelGroup; >+ XSDModelGroup modelGroup = null; >+ if (isResourcePropertyElementEmpty()) >+ { >+ modelGroup = createNewXSDModelGroup(); >+ } >+ else >+ { >+ XSDComplexTypeDefinition typeDef = (XSDComplexTypeDefinition) _resourcePropertyElement >+ .getAnonymousTypeDefinition(); >+ modelGroup = XsdUtils.getXSDModelGroup(typeDef); >+ } >+ return modelGroup; > } > > private XSDModelGroup createNewXSDModelGroup() > { >- XSDModelGroup 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); >- >- return modelGroup; >+ XSDModelGroup 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); >+ >+ return modelGroup; > } > > /** >@@ -203,6 +203,6 @@ > */ > public Property getProperty() > { >- return _property; >+ return _property; > } > } >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/property/internal/ChangeMutabilityCommand.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.editor.capability/src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/property/internal/ChangeMutabilityCommand.java,v >retrieving revision 1.3 >diff -u -r1.3 ChangeMutabilityCommand.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/property/internal/ChangeMutabilityCommand.java 9 Jan 2007 19:51:43 -0000 1.3 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/property/internal/ChangeMutabilityCommand.java 20 Jan 2007 13:33:31 -0000 >@@ -12,11 +12,10 @@ > > package org.eclipse.tptp.wsdm.tooling.editor.capability.command.property.internal; > >-import org.eclipse.emf.ecore.xml.type.internal.QName; > import org.eclipse.tptp.wsdm.tooling.editor.capability.internal.CapabilityDomain; > import org.eclipse.tptp.wsdm.tooling.editor.capability.util.internal.MetaDataUtils; > import org.eclipse.tptp.wsdm.tooling.model.capabilities.Property; >-import org.eclipse.tptp.wsdm.tooling.util.internal.PropertyMetaDataDescriptor; >+import org.eclipse.tptp.wsdm.tooling.model.capabilities.impl.MetadataDescriptor; > import org.eclipse.tptp.wsdm.tooling.util.internal.XsdUtils; > > /** >@@ -37,8 +36,8 @@ > public ChangeMutabilityCommand(CapabilityDomain capabilityDomain, > Property property, String mutability) > { >- super(capabilityDomain, property); >- _mutability = mutability; >+ super(capabilityDomain, property); >+ _mutability = mutability; > } > > /** >@@ -47,24 +46,21 @@ > */ > public void execute() > { >- PropertyMetaDataDescriptor metaDataDescriptor = _capabilityDomain >- .getMetaDataDescriptor(); >- if (_capabilityDomain.getMetaDataDescriptor() == null) >- { >- metaDataDescriptor = createMetaDataDescriptor(); >- } >- >- if (_metadata == null) >- { >- _metadata = metaDataDescriptor.createNewPropertyType(); >- _property.setMetaData(_metadata); >- String ns = _property.getElement().getTargetNamespace(); >- String name = XsdUtils.getName(_property.getElement()); >- String prefix = metaDataDescriptor.getOrCreatePrefix(ns); >- _metadata.setName(new QName(ns, name, prefix)); >- } >- >- _metadata.setMutability(MetaDataUtils.getMutabilityType(_mutability)); >+ MetadataDescriptor metaDataDescriptor = _capabilityDomain.getCapability().getMetadata(); >+ if (metaDataDescriptor == null) >+ metaDataDescriptor = createMetaDataDescriptor(); >+ >+ if (_metadata == null) >+ { >+ _metadata = metaDataDescriptor.createNewPropertyType(); >+ _property.setMetaData(_metadata); >+ String ns = _property.getElement().getTargetNamespace(); >+ String name = XsdUtils.getName(_property.getElement()); >+ String prefix = metaDataDescriptor.getOrCreatePrefix(ns); >+ _metadata.setName(prefix+":"+name); >+ } >+ >+ _metadata.setMutability(MetaDataUtils.getMutabilityType(_mutability)); > } > > } >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/property/internal/ChangeModifiabilityCommand.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.editor.capability/src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/property/internal/ChangeModifiabilityCommand.java,v >retrieving revision 1.3 >diff -u -r1.3 ChangeModifiabilityCommand.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/property/internal/ChangeModifiabilityCommand.java 9 Jan 2007 19:51:43 -0000 1.3 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/property/internal/ChangeModifiabilityCommand.java 20 Jan 2007 13:33:31 -0000 >@@ -12,11 +12,10 @@ > > package org.eclipse.tptp.wsdm.tooling.editor.capability.command.property.internal; > >-import org.eclipse.emf.ecore.xml.type.internal.QName; > import org.eclipse.tptp.wsdm.tooling.editor.capability.internal.CapabilityDomain; > import org.eclipse.tptp.wsdm.tooling.editor.capability.util.internal.MetaDataUtils; > import org.eclipse.tptp.wsdm.tooling.model.capabilities.Property; >-import org.eclipse.tptp.wsdm.tooling.util.internal.PropertyMetaDataDescriptor; >+import org.eclipse.tptp.wsdm.tooling.model.capabilities.impl.MetadataDescriptor; > import org.eclipse.tptp.wsdm.tooling.util.internal.XsdUtils; > > /** >@@ -37,8 +36,8 @@ > public ChangeModifiabilityCommand(CapabilityDomain capabilityDomain, > Property property, String modifiability) > { >- super(capabilityDomain, property); >- _modifiability = modifiability; >+ super(capabilityDomain, property); >+ _modifiability = modifiability; > } > > /** >@@ -47,24 +46,21 @@ > */ > public void execute() > { >- PropertyMetaDataDescriptor metaDataDescriptor = _capabilityDomain >- .getMetaDataDescriptor(); >- if (_capabilityDomain.getMetaDataDescriptor() == null) >- { >- metaDataDescriptor = createMetaDataDescriptor(); >- } >- >- if (_metadata == null) >- { >- _metadata = metaDataDescriptor.createNewPropertyType(); >- _property.setMetaData(_metadata); >- String ns = _property.getElement().getTargetNamespace(); >- String name = XsdUtils.getName(_property.getElement()); >- String prefix = metaDataDescriptor.getOrCreatePrefix(ns); >- _metadata.setName(new QName(ns, name, prefix)); >- } >- >- _metadata.setModifiability(MetaDataUtils >- .getModifiabilityType(_modifiability)); >+ MetadataDescriptor metaDataDescriptor = _capabilityDomain.getCapability().getMetadata(); >+ if (metaDataDescriptor == null) >+ metaDataDescriptor = createMetaDataDescriptor(); >+ >+ if (_metadata == null) >+ { >+ _metadata = metaDataDescriptor.createNewPropertyType(); >+ _property.setMetaData(_metadata); >+ String ns = _property.getElement().getTargetNamespace(); >+ String name = XsdUtils.getName(_property.getElement()); >+ String prefix = metaDataDescriptor.getOrCreatePrefix(ns); >+ _metadata.setName(prefix+":"+name); >+ } >+ >+ _metadata.setModifiability(MetaDataUtils >+ .getModifiabilityType(_modifiability)); > } > } >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/property/internal/MetaDataCommand.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.editor.capability/src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/property/internal/MetaDataCommand.java,v >retrieving revision 1.3 >diff -u -r1.3 MetaDataCommand.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/property/internal/MetaDataCommand.java 9 Jan 2007 19:51:43 -0000 1.3 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/property/internal/MetaDataCommand.java 20 Jan 2007 13:33:32 -0000 >@@ -15,9 +15,8 @@ > import org.eclipse.tptp.wsdm.tooling.editor.capability.internal.CapabilityDomain; > import org.eclipse.tptp.wsdm.tooling.editor.capability.util.internal.MetaDataUtils; > import org.eclipse.tptp.wsdm.tooling.model.capabilities.Property; >+import org.eclipse.tptp.wsdm.tooling.model.capabilities.impl.MetadataDescriptor; > import org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.PropertyType; >-import org.eclipse.tptp.wsdm.tooling.util.internal.PropertyMetaDataDescriptor; >- > > /** > * >@@ -38,18 +37,18 @@ > */ > public MetaDataCommand(CapabilityDomain capabilityDomain, Property property) > { >- _capabilityDomain = capabilityDomain; >- _property = property; >- _metadata = property.getMetaData(); >+ _capabilityDomain = capabilityDomain; >+ _property = property; >+ _metadata = property.getMetaData(); > } > > /** > * Creates a new metaDataDescriptor for the property. > */ >- protected PropertyMetaDataDescriptor createMetaDataDescriptor() >+ protected MetadataDescriptor createMetaDataDescriptor() > { >- PropertyMetaDataDescriptor propertyMetaDataDescriptor = MetaDataUtils.createMetaDataDescriptor(_capabilityDomain); >- return propertyMetaDataDescriptor; >+ MetadataDescriptor propertyMetaDataDescriptor = MetaDataUtils.createMetaDataDescriptor(_capabilityDomain); >+ return propertyMetaDataDescriptor; > } > > } >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/operation/internal/ParamSection.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.editor.capability/src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/operation/internal/ParamSection.java,v >retrieving revision 1.8 >diff -u -r1.8 ParamSection.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/operation/internal/ParamSection.java 9 Jan 2007 19:51:44 -0000 1.8 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/operation/internal/ParamSection.java 20 Jan 2007 13:33:37 -0000 >@@ -82,7 +82,7 @@ > public ParamSection(CapabilityEditor editor, IUIPage page, > ScrolledForm form, FormToolkit toolkit) > { >- super(editor, page, form, toolkit); >+ super(editor, page, form, toolkit); > } > > /** >@@ -90,148 +90,148 @@ > */ > public void create() > { >- Composite sectionClient = createSection(Messages.PARAMETERS, >- Messages.PARAM_OF_OP); >- GridLayout layout = new GridLayout(2, false); >- layout.marginWidth = LAYOUT_MARGIN_WIDTH; >- layout.verticalSpacing = LAYOUT_VERTICAL_SPACING; >- layout.horizontalSpacing = LAYOUT_HORIZONTAL_SPACING; >- sectionClient.setLayout(layout); >- FormToolkit toolkit = getToolkit(); >- >- _paramViewer = new StructuredTableViewer(sectionClient, toolkit, >- SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION, >- this); >- Table table = (Table) _paramViewer.getControl(); >- GridData gd = new GridData(GridData.FILL_BOTH); >- gd.widthHint = GridData.HORIZONTAL_ALIGN_FILL; >- gd.heightHint = 100; >- _paramViewer.getControl().setLayoutData(gd); >- >- /*TableColumn column = new TableColumn(table, SWT.NONE, 0); >- column.setText(""); >- column.setWidth(20); >- column.setResizable(false);*/ >- >- TableColumn column = new TableColumn(table, SWT.NONE, 0); >- column.setText(Messages.PARAM_NAME); >- column.setWidth(100); >- >- column = new TableColumn(table, SWT.NONE, 1); >- column.setText(Messages.PARAM_TYPE); >- column.setWidth(100); >- >- table.redraw(); >- table.setHeaderVisible(true); >- table.setLinesVisible(true); >- _paramViewer.setContentProvider(new ParamContentProvider()); >- _paramViewer.setLabelProvider(new ParamLabelProvider()); >- >- Composite buttonComposite = toolkit.createComposite(sectionClient); >- layout = new GridLayout(); >- layout.marginHeight = 0; >- buttonComposite.setLayout(layout); >- gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING >- | GridData.VERTICAL_ALIGN_FILL); >- gd.horizontalSpan = 1; >- buttonComposite.setLayoutData(gd); >- >- _addParameterButton = toolkit >- .createButton( >- buttonComposite, >- org.eclipse.tptp.wsdm.tooling.nls.messages.capability.internal.Messages.ADD_BUTTON_LABEL, >- SWT.PUSH); >- gd = new GridData(GridData.FILL_HORIZONTAL >- | GridData.VERTICAL_ALIGN_BEGINNING); >- _addParameterButton.setLayoutData(gd); >- _addParameterButton.addListener(SWT.Selection, new Listener() >- { >- public void handleEvent(Event event) >- { >- addParameter(); >- } >- }); >- >- _editParameterButton = toolkit >- .createButton( >- buttonComposite, >- org.eclipse.tptp.wsdm.tooling.nls.messages.capability.internal.Messages.EDIT_BUTTON_LABEL, >- SWT.PUSH); >- gd = new GridData(GridData.FILL_HORIZONTAL >- | GridData.VERTICAL_ALIGN_BEGINNING); >- _editParameterButton.setLayoutData(gd); >- _editParameterButton.addListener(SWT.Selection, new Listener() >- { >- public void handleEvent(Event event) >- { >- editParameter(); >- } >- }); >- _editParameterButton.setEnabled(false); >- >- _removeParameterButton = toolkit >- .createButton( >- buttonComposite, >- org.eclipse.tptp.wsdm.tooling.nls.messages.capability.internal.Messages.REMOVE_BUTTON_LABEL, >- SWT.PUSH); >- gd = new GridData(GridData.FILL_HORIZONTAL >- | GridData.VERTICAL_ALIGN_BEGINNING); >- _removeParameterButton.setLayoutData(gd); >- _removeParameterButton.addListener(SWT.Selection, new Listener() >- { >- public void handleEvent(Event event) >- { >- removeParameter(); >- } >- }); >- _removeParameterButton.setEnabled(false); >+ Composite sectionClient = createSection(Messages.PARAMETERS, >+ Messages.PARAM_OF_OP); >+ GridLayout layout = new GridLayout(2, false); >+ layout.marginWidth = LAYOUT_MARGIN_WIDTH; >+ layout.verticalSpacing = LAYOUT_VERTICAL_SPACING; >+ layout.horizontalSpacing = LAYOUT_HORIZONTAL_SPACING; >+ sectionClient.setLayout(layout); >+ FormToolkit toolkit = getToolkit(); >+ >+ _paramViewer = new StructuredTableViewer(sectionClient, toolkit, >+ SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION, >+ this); >+ Table table = (Table) _paramViewer.getControl(); >+ GridData gd = new GridData(GridData.FILL_BOTH); >+ gd.widthHint = GridData.HORIZONTAL_ALIGN_FILL; >+ gd.heightHint = 100; >+ _paramViewer.getControl().setLayoutData(gd); >+ >+ /*TableColumn column = new TableColumn(table, SWT.NONE, 0); >+ column.setText(""); >+ column.setWidth(20); >+ column.setResizable(false);*/ >+ >+ TableColumn column = new TableColumn(table, SWT.NONE, 0); >+ column.setText(Messages.PARAM_NAME); >+ column.setWidth(100); >+ >+ column = new TableColumn(table, SWT.NONE, 1); >+ column.setText(Messages.PARAM_TYPE); >+ column.setWidth(100); >+ >+ table.redraw(); >+ table.setHeaderVisible(true); >+ table.setLinesVisible(true); >+ _paramViewer.setContentProvider(new ParamContentProvider()); >+ _paramViewer.setLabelProvider(new ParamLabelProvider()); >+ >+ Composite buttonComposite = toolkit.createComposite(sectionClient); >+ layout = new GridLayout(); >+ layout.marginHeight = 0; >+ buttonComposite.setLayout(layout); >+ gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING >+ | GridData.VERTICAL_ALIGN_FILL); >+ gd.horizontalSpan = 1; >+ buttonComposite.setLayoutData(gd); >+ >+ _addParameterButton = toolkit >+ .createButton( >+ buttonComposite, >+ org.eclipse.tptp.wsdm.tooling.nls.messages.capability.internal.Messages.ADD_BUTTON_LABEL, >+ SWT.PUSH); >+ gd = new GridData(GridData.FILL_HORIZONTAL >+ | GridData.VERTICAL_ALIGN_BEGINNING); >+ _addParameterButton.setLayoutData(gd); >+ _addParameterButton.addListener(SWT.Selection, new Listener() >+ { >+ public void handleEvent(Event event) >+ { >+ addParameter(); >+ } >+ }); >+ >+ _editParameterButton = toolkit >+ .createButton( >+ buttonComposite, >+ org.eclipse.tptp.wsdm.tooling.nls.messages.capability.internal.Messages.EDIT_BUTTON_LABEL, >+ SWT.PUSH); >+ gd = new GridData(GridData.FILL_HORIZONTAL >+ | GridData.VERTICAL_ALIGN_BEGINNING); >+ _editParameterButton.setLayoutData(gd); >+ _editParameterButton.addListener(SWT.Selection, new Listener() >+ { >+ public void handleEvent(Event event) >+ { >+ editParameter(); >+ } >+ }); >+ _editParameterButton.setEnabled(false); >+ >+ _removeParameterButton = toolkit >+ .createButton( >+ buttonComposite, >+ org.eclipse.tptp.wsdm.tooling.nls.messages.capability.internal.Messages.REMOVE_BUTTON_LABEL, >+ SWT.PUSH); >+ gd = new GridData(GridData.FILL_HORIZONTAL >+ | GridData.VERTICAL_ALIGN_BEGINNING); >+ _removeParameterButton.setLayoutData(gd); >+ _removeParameterButton.addListener(SWT.Selection, new Listener() >+ { >+ public void handleEvent(Event event) >+ { >+ removeParameter(); >+ } >+ }); >+ _removeParameterButton.setEnabled(false); > } > > private void addParameter() > { >- java.util.List paramList = (List) _paramViewer.getInput(); >- NewParameterDialog dlg = new NewParameterDialog(getForm().getShell(), >- Messages.ADD_PARAM, paramList, null); >- if (dlg.open() == Window.OK) >- { >- InputParameter parameter = dlg.getParameter(); >- AddParameterCommand command = new AddParameterCommand( >- _selectedOperation, parameter); >- command.execute(); >- _selectedParam = parameter; >- _page.setDirty(); >- } >+ java.util.List paramList = (List) _paramViewer.getInput(); >+ NewParameterDialog dlg = new NewParameterDialog(getForm().getShell(), >+ Messages.ADD_PARAM, paramList, null); >+ if (dlg.open() == Window.OK) >+ { >+ InputParameter parameter = dlg.getParameter(); >+ AddParameterCommand command = new AddParameterCommand( >+ _selectedOperation, parameter); >+ command.execute(); >+ _selectedParam = parameter; >+ _page.setDirty(); >+ } > } > > private void editParameter() > { >- Object[] objects = _paramViewer.getSelectedObjets(); >- if (objects != null && objects.length != 0) >- { >- InputParameter parameter = (InputParameter) objects[0]; >- java.util.List paramList = (List) _paramViewer.getInput(); >- NewParameterDialog dlg = new NewParameterDialog(getForm().getShell(), >- Messages.EDIT_PARAM, paramList, parameter); >- if (dlg.open() == Window.OK) >- { >- _selectedParam = parameter; >- _page.setDirty(); >- } >- } >+ Object[] objects = _paramViewer.getSelectedObjets(); >+ if (objects != null && objects.length != 0) >+ { >+ InputParameter parameter = (InputParameter) objects[0]; >+ java.util.List paramList = (List) _paramViewer.getInput(); >+ NewParameterDialog dlg = new NewParameterDialog(getForm().getShell(), >+ Messages.EDIT_PARAM, paramList, parameter); >+ if (dlg.open() == Window.OK) >+ { >+ _selectedParam = parameter; >+ _page.setDirty(); >+ } >+ } > } > > private void removeParameter() > { >- Object[] objects = _paramViewer.getSelectedObjets(); >- if (objects != null && objects.length != 0) >- { >- InputParameter parameter = (InputParameter) objects[0]; >- RemoveParameterCommand command = new RemoveParameterCommand( >- _selectedOperation, parameter); >- command.execute(); >- _selectedParam = null; >- _page.setDirty(); >- } >+ Object[] objects = _paramViewer.getSelectedObjets(); >+ if (objects != null && objects.length != 0) >+ { >+ InputParameter parameter = (InputParameter) objects[0]; >+ RemoveParameterCommand command = new RemoveParameterCommand( >+ _selectedOperation, parameter); >+ command.execute(); >+ _selectedParam = null; >+ _page.setDirty(); >+ } > } > > /** >@@ -239,10 +239,10 @@ > */ > public void refresh() > { >- if (_selectedParam != null) >- { >- setFocusToParameter(_selectedParam); >- } >+ if (_selectedParam != null) >+ { >+ setFocusToParameter(_selectedParam); >+ } > } > > /** >@@ -257,52 +257,52 @@ > */ > public void selectionChanged(SelectionChangedEvent event) > { >- showSelectedOperationParameters(); >- // TODO Remove this once able to handle WSDL Import properly >- enableDisableParamSection(); >+ showSelectedOperationParameters(); >+ // TODO Remove this once able to handle WSDL Import properly >+ enableDisableParamSection(); > } > > private void showSelectedOperationParameters() > { >- XSDElementDeclaration[] parameters = WsdlUtils >- .getOperationParams(_selectedOperation); >- _editParameterButton.setEnabled(false); >- _removeParameterButton.setEnabled(false); >- List paramList = new LinkedList(); >- for (int i = 0; i < parameters.length; i++) >- { >- String type = XsdUtils.getType(parameters[i]); >- XSDTypeDefinition typeDefinition = XsdUtils >- .getXSDTypeDefinition(parameters[i]); >- DataType dataType = new DataType(type, typeDefinition); >- boolean isArrayType = false; >- if(parameters[i].eContainer() instanceof XSDParticle) >- { >- XSDParticle particle = (XSDParticle) parameters[i].eContainer(); >- isArrayType = particle.getMaxOccurs()==-1?true:false; >- } >- InputParameter param = new InputParameter(parameters[i], dataType, isArrayType); >- paramList.add(param); >- } >- _paramViewer.setInput(paramList); >+ XSDElementDeclaration[] parameters = WsdlUtils >+ .getOperationParams(_selectedOperation); >+ _editParameterButton.setEnabled(false); >+ _removeParameterButton.setEnabled(false); >+ List paramList = new LinkedList(); >+ for (int i = 0; i < parameters.length; i++) >+ { >+ String type = XsdUtils.getType(parameters[i]); >+ XSDTypeDefinition typeDefinition = XsdUtils >+ .getXSDTypeDefinition(parameters[i]); >+ DataType dataType = new DataType(type, typeDefinition); >+ boolean isArrayType = false; >+ if(parameters[i].eContainer() instanceof XSDParticle) >+ { >+ XSDParticle particle = (XSDParticle) parameters[i].eContainer(); >+ isArrayType = particle.getMaxOccurs()==-1?true:false; >+ } >+ InputParameter param = new InputParameter(parameters[i], dataType, isArrayType); >+ paramList.add(param); >+ } >+ _paramViewer.setInput(paramList); > } > > private void enableDisableParamSection() > { >- Definition capDefinition = _editor.getCapabilityDomain() >- .getDefinition(); >- Message operationMessage = _selectedOperation.getEInput().getEMessage(); >- boolean isImportedOperation = true; >- if (operationMessage != null) >- isImportedOperation = !operationMessage.getEnclosingDefinition() >- .equals(capDefinition); >- >- _addParameterButton.setEnabled(!isImportedOperation && !_editor.isReadOnly()); >- _editParameterButton.setEnabled(!isImportedOperation >- && _editParameterButton.getEnabled() && !_editor.isReadOnly()); >- _removeParameterButton.setEnabled(!isImportedOperation >- && _removeParameterButton.getEnabled() && !_editor.isReadOnly()); >- _paramViewer.getControl().setEnabled(!isImportedOperation); >+ Definition capDefinition = _editor.getCapabilityDomain().getCapability() >+ .getDefinition(); >+ Message operationMessage = _selectedOperation.getEInput().getEMessage(); >+ boolean isImportedOperation = true; >+ if (operationMessage != null) >+ isImportedOperation = !operationMessage.getEnclosingDefinition() >+ .equals(capDefinition); >+ >+ _addParameterButton.setEnabled(!isImportedOperation && !_editor.isReadOnly()); >+ _editParameterButton.setEnabled(!isImportedOperation >+ && _editParameterButton.getEnabled() && !_editor.isReadOnly()); >+ _removeParameterButton.setEnabled(!isImportedOperation >+ && _removeParameterButton.getEnabled() && !_editor.isReadOnly()); >+ _paramViewer.getControl().setEnabled(!isImportedOperation); > } > > /** >@@ -310,8 +310,8 @@ > */ > public void setSelectedObject(Object object) > { >- if (object instanceof Operation) >- _selectedOperation = (Operation) object; >+ if (object instanceof Operation) >+ _selectedOperation = (Operation) object; > } > > /** >@@ -326,13 +326,13 @@ > */ > public void handleSelectionChanged(SelectionChangedEvent event) > { >- Object[] objects = _paramViewer.getSelectedObjets(); >- _editParameterButton.setEnabled(objects.length != 0 && !_editor.isReadOnly()); >- _removeParameterButton.setEnabled(objects.length != 0 && !_editor.isReadOnly()); >- if (objects.length > 0) >- { >- _selectedParam = (InputParameter) objects[0]; >- } >+ Object[] objects = _paramViewer.getSelectedObjets(); >+ _editParameterButton.setEnabled(objects.length != 0 && !_editor.isReadOnly()); >+ _removeParameterButton.setEnabled(objects.length != 0 && !_editor.isReadOnly()); >+ if (objects.length > 0) >+ { >+ _selectedParam = (InputParameter) objects[0]; >+ } > } > > /** >@@ -340,18 +340,18 @@ > */ > public void enable(boolean enabled) > { >- _addParameterButton.setEnabled(enabled); >- _editParameterButton.setEnabled(enabled); >- _removeParameterButton.setEnabled(enabled); >- if (!enabled) >- _paramViewer.setInput(new LinkedList()); >+ _addParameterButton.setEnabled(enabled); >+ _editParameterButton.setEnabled(enabled); >+ _removeParameterButton.setEnabled(enabled); >+ if (!enabled) >+ _paramViewer.setInput(new LinkedList()); > } > > private void setFocusToParameter(InputParameter param) > { >- _selectedParam = param; >- _paramViewer.setSelection(new StructuredSelection(_selectedParam), >- false); >+ _selectedParam = param; >+ _paramViewer.setSelection(new StructuredSelection(_selectedParam), >+ false); > } > > } >@@ -361,12 +361,12 @@ > > public Object[] getElements(Object inputElement) > { >- if (inputElement instanceof Collection) >- { >- Collection c = (Collection) inputElement; >- return c.toArray(); >- } >- return new Object[0]; >+ if (inputElement instanceof Collection) >+ { >+ Collection c = (Collection) inputElement; >+ return c.toArray(); >+ } >+ return new Object[0]; > } > > public void dispose() >@@ -384,29 +384,29 @@ > > public String getColumnText(Object element, int columnIndex) > { >- String text = ""; >- switch (columnIndex) >- { >- case 0: >- { >- InputParameter param = (InputParameter) element; >- text = param.getXSDElementDeclaration().getName(); >- break; >- } >- case 1: >- { >- InputParameter param = (InputParameter) element; >- XSDFeature featureDeclaration = param.getXSDElementDeclaration(); >- text = XsdUtils.getType(featureDeclaration); >- if(param.isArrayType()) >- text = text+"[]"; >- } >- } >- return text; >+ String text = ""; >+ switch (columnIndex) >+ { >+ case 0: >+ { >+ InputParameter param = (InputParameter) element; >+ text = param.getXSDElementDeclaration().getName(); >+ break; >+ } >+ case 1: >+ { >+ InputParameter param = (InputParameter) element; >+ XSDFeature featureDeclaration = param.getXSDElementDeclaration(); >+ text = XsdUtils.getType(featureDeclaration); >+ if(param.isArrayType()) >+ text = text+"[]"; >+ } >+ } >+ return text; > } > > public Image getColumnImage(Object element, int columnIndex) > { >- return null; >+ return null; > } > } >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/operation/internal/ListSection.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.editor.capability/src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/operation/internal/ListSection.java,v >retrieving revision 1.8 >diff -u -r1.8 ListSection.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/operation/internal/ListSection.java 9 Jan 2007 19:51:43 -0000 1.8 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/operation/internal/ListSection.java 20 Jan 2007 13:33:35 -0000 >@@ -69,336 +69,343 @@ > public class ListSection extends AbstractPageSection implements IViewerClient > { > >- private StructuredTableViewer _operationsViewer; >+ private StructuredTableViewer _operationsViewer; > >- private Button _addOperationButton; >+ private Button _addOperationButton; > >- private Button _removeOperationButton; >+ private Button _removeOperationButton; > >- private Label _errorLabel; >+ private Label _errorLabel; > >- private Operation _selectedOperation; >- >- private Composite _sectionClient; >- >- private Composite _buttonClient; >- >- /** >- * Creates a new object of this class. >- */ >- ListSection(CapabilityEditor editor, IUIPage page, ScrolledForm form, >- FormToolkit toolkit) >- { >- super(editor, page, form, toolkit); >- } >- >- /** >- * Creates the section. >- */ >- public void create() >- { >- _sectionClient = createSection(Messages.OPERATIONS, >- Messages.OPERATIONS_OF_CAP, 1, 3); >- GridLayout layout = new GridLayout(2, false); >- layout.marginWidth = LAYOUT_MARGIN_WIDTH; >- layout.verticalSpacing = LAYOUT_VERTICAL_SPACING; >- _sectionClient.setLayout(layout); >- FormToolkit toolkit = getToolkit(); >- >- _operationsViewer = new StructuredTableViewer(_sectionClient, toolkit, >- SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER, this); >- >- GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); >- gd.heightHint = 50; >- gd.widthHint = 50; >- _operationsViewer.getControl().setLayoutData(gd); >- _operationsViewer.getControl().setData(FormToolkit.KEY_DRAW_BORDER, >- FormToolkit.TREE_BORDER); >- >- // Set up a label provider that knows about the capability (so can >- // extract SemanticDecorations from it) >- OperationContentProvider provider = new OperationContentProvider(); >- _operationsViewer.setContentProvider(provider); >- _operationsViewer.setLabelProvider(new OperationLabelProvider(getForm() >- .getShell())); >- _operationsViewer.getControl().setSize(_operationsViewer.getControl().computeSize(SWT.DEFAULT, SWT.DEFAULT)); >- >- _buttonClient = toolkit.createComposite(_sectionClient); >- layout = new GridLayout(); >- layout.marginHeight = 0; >- _buttonClient.setLayout(layout); >- gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_FILL, false, false); >- _buttonClient.setLayoutData(gd); >- >- _addOperationButton = createPushButton( >- _buttonClient, >- toolkit, >- org.eclipse.tptp.wsdm.tooling.nls.messages.capability.internal.Messages.ADD_BUTTON_LABEL, >- new Listener() >+ private Operation _selectedOperation; >+ >+ private Composite _sectionClient; >+ >+ private Composite _buttonClient; >+ >+ /** >+ * Creates a new object of this class. >+ */ >+ ListSection(CapabilityEditor editor, IUIPage page, ScrolledForm form, >+ FormToolkit toolkit) >+ { >+ super(editor, page, form, toolkit); >+ } >+ >+ /** >+ * Creates the section. >+ */ >+ public void create() >+ { >+ _sectionClient = createSection(Messages.OPERATIONS, >+ Messages.OPERATIONS_OF_CAP, 1, 3); >+ GridLayout layout = new GridLayout(2, false); >+ layout.marginWidth = LAYOUT_MARGIN_WIDTH; >+ layout.verticalSpacing = LAYOUT_VERTICAL_SPACING; >+ _sectionClient.setLayout(layout); >+ FormToolkit toolkit = getToolkit(); >+ >+ _operationsViewer = new StructuredTableViewer(_sectionClient, toolkit, >+ SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER, this); >+ >+ GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); >+ gd.heightHint = 50; >+ gd.widthHint = 50; >+ _operationsViewer.getControl().setLayoutData(gd); >+ _operationsViewer.getControl().setData(FormToolkit.KEY_DRAW_BORDER, >+ FormToolkit.TREE_BORDER); >+ >+ // Set up a label provider that knows about the capability (so can >+ // extract SemanticDecorations from it) >+ OperationContentProvider provider = new OperationContentProvider(); >+ _operationsViewer.setContentProvider(provider); >+ _operationsViewer.setLabelProvider(new OperationLabelProvider(getForm() >+ .getShell())); >+ _operationsViewer.getControl().setSize( >+ _operationsViewer.getControl().computeSize(SWT.DEFAULT, >+ SWT.DEFAULT)); >+ >+ _buttonClient = toolkit.createComposite(_sectionClient); >+ layout = new GridLayout(); >+ layout.marginHeight = 0; >+ _buttonClient.setLayout(layout); >+ gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, >+ GridData.VERTICAL_ALIGN_FILL, false, false); >+ _buttonClient.setLayoutData(gd); >+ >+ _addOperationButton = createPushButton( >+ _buttonClient, >+ toolkit, >+ org.eclipse.tptp.wsdm.tooling.nls.messages.capability.internal.Messages.ADD_BUTTON_LABEL, >+ new Listener() { >+ public void handleEvent(Event event) >+ { >+ addOperation(); >+ } >+ }); >+ gd = new GridData(GridData.CENTER, SWT.NONE, false, false); >+ gd.widthHint = 50; >+ _addOperationButton.setLayoutData(gd); >+ _addOperationButton.setEnabled(!_editor.isReadOnly()); >+ >+ _removeOperationButton = createPushButton( >+ _buttonClient, >+ toolkit, >+ org.eclipse.tptp.wsdm.tooling.nls.messages.capability.internal.Messages.REMOVE_BUTTON_LABEL, >+ new Listener() { >+ public void handleEvent(Event event) >+ { >+ removeOperation(); >+ } >+ }); >+ gd = new GridData(GridData.CENTER, SWT.NONE, false, false); >+ gd.widthHint = 50; >+ _removeOperationButton.setLayoutData(gd); >+ _removeOperationButton.setEnabled(false); >+ >+ _errorLabel = toolkit.createLabel(_sectionClient, "", SWT.WRAP); >+ gd = new GridData(); >+ gd.grabExcessHorizontalSpace = true; >+ gd.horizontalAlignment = SWT.FILL; >+ gd.horizontalSpan = 2; >+ _errorLabel.setLayoutData(gd); >+ } >+ >+ private void addOperation() >+ { >+ CapabilityDomain capabilityDomain = _editor.getCapabilityDomain(); >+ NewOperationDialog dlg = new NewOperationDialog(getForm().getShell(), >+ Messages.ADD_OPERATION, capabilityDomain); >+ int choice = dlg.open(); >+ if (choice == Window.OK) > { >- public void handleEvent(Event event) >- { >- addOperation(); >- } >- }); >- gd = new GridData(GridData.CENTER, SWT.NONE, false, false); >- gd.widthHint = 50; >- _addOperationButton.setLayoutData(gd); >- _addOperationButton.setEnabled(!_editor.isReadOnly()); >- >- _removeOperationButton = createPushButton( >- _buttonClient, >- toolkit, >- org.eclipse.tptp.wsdm.tooling.nls.messages.capability.internal.Messages.REMOVE_BUTTON_LABEL, >- new Listener() >+ Operation operation = dlg.getOperation(); >+ AddOperationCommand command_1 = new AddOperationCommand( >+ capabilityDomain, operation); >+ command_1.execute(); >+ operation = command_1.getOperation(); >+ >+ // Change the return type of new operation >+ DataType returnType = dlg.getReturnType(); >+ ChangeOperationReturnTypeCommand command_2 = new ChangeOperationReturnTypeCommand( >+ operation, returnType); >+ command_2.execute(); >+ >+ // Change the types of input parameters >+ java.util.List paramList = dlg.getInputParams(); >+ for (int i = 0; i < paramList.size(); i++) >+ { >+ InputParameter param = (InputParameter) paramList.get(i); >+ ChangeInputParamTypeCommand command = new ChangeInputParamTypeCommand( >+ param, param.getDataType()); >+ command.execute(); >+ } >+ >+ _selectedOperation = operation; >+ _page.setDirty(); >+ } >+ } >+ >+ private void removeOperation() >+ { >+ CapabilityDomain capabilityDomain = _editor.getCapabilityDomain(); >+ RemoveOperationCommand command = new RemoveOperationCommand( >+ capabilityDomain, _selectedOperation); >+ command.execute(); >+ _selectedOperation = null; >+ _page.setDirty(); >+ } >+ >+ /** >+ * Refreshes the section. >+ */ >+ public void refresh() >+ { >+ Capability capability = _editor.getCapabilityDomain().getCapability(); >+ List operations = capability.getOperations(); >+ _operationsViewer.setInput(operations); >+ if (operations.size() != 0 && _selectedOperation != null) >+ { >+ _page.enableSections(true); >+ setFocusToOperation(_selectedOperation); >+ } >+ else >+ { >+ _page.enableSections(false); >+ } >+ updateErrorMessage(); >+ } >+ >+ private void updateErrorMessage() >+ { >+ Definition defintion = _editor.getCapabilityDomain().getCapability() >+ .getDefinition(); >+ CapabilityWSDLValidator validator = new CapabilityWSDLValidator(); >+ IValidationReport report = validator.validate(defintion); >+ boolean hasProblem = report.hasErrors() || report.hasWarnings(); >+ if (hasProblem) > { >- public void handleEvent(Event event) >- { >- removeOperation(); >- } >+ // We have a problem, is it an error or just a warning? >+ boolean hasError = false; >+ String msg; >+ if (report.hasErrors()) >+ { >+ hasError = true; >+ msg = report.getErrorMessages()[0].getMessage(); >+ } >+ else >+ { >+ msg = report.getWarningMessages()[0].getMessage(); >+ } >+ _errorLabel.setBackground(getForm().getDisplay().getSystemColor( >+ hasError ? SWT.COLOR_RED : SWT.COLOR_YELLOW)); >+ _errorLabel.setForeground(getForm().getDisplay().getSystemColor( >+ hasError ? SWT.COLOR_WHITE : SWT.COLOR_BLACK)); >+ _errorLabel.setText(" " + msg + " "); >+ } >+ else >+ { >+ _errorLabel.setBackground(getForm().getBackground()); >+ _errorLabel.setForeground(getForm().getForeground()); >+ _errorLabel.setText(""); >+ } >+ } >+ >+ /** >+ * Handle double click. >+ */ >+ public void handleDoubleClick() >+ { >+ } >+ >+ /** >+ * Handle selection changed. >+ */ >+ public void handleSelectionChanged(SelectionChangedEvent event) >+ { >+ Object[] objects = _operationsViewer.getSelectedObjets(); >+ _removeOperationButton.setEnabled(objects.length > 0 >+ && !_editor.isReadOnly()); >+ if (objects.length > 0) >+ { >+ _selectedOperation = (Operation) objects[0]; >+ _page.enableSections(true); >+ List sections = _page.getSections(); >+ for (int i = 0; i < sections.size(); i++) >+ { >+ IPageSection section = (IPageSection) sections.get(i); >+ section.setSelectedObject(_selectedOperation); >+ section.selectionChanged(event); >+ } >+ } >+ } >+ >+ /** >+ * Initialized control listeners. >+ */ >+ public void hookAllListeners() >+ { >+ getForm().addControlListener(new ControlAdapter() { >+ public void controlResized(ControlEvent e) >+ { >+ Rectangle formBounds = getForm().getClientArea(); >+ Rectangle sectionClientBounds = _sectionClient.getClientArea(); >+ Rectangle buttonCompositeBounds = _buttonClient.getClientArea(); >+ int width = sectionClientBounds.width >+ - buttonCompositeBounds.width - 20; >+ int height = Math.min(formBounds.height, >+ sectionClientBounds.height) - 100; >+ Table table = (Table) _operationsViewer.getControl(); >+ table.setSize(width, height); >+ } > }); >- gd = new GridData(GridData.CENTER, SWT.NONE, false, false); >- gd.widthHint = 50; >- _removeOperationButton.setLayoutData(gd); >- _removeOperationButton.setEnabled(false); >- >- _errorLabel = toolkit.createLabel(_sectionClient, "", SWT.WRAP); >- gd = new GridData(); >- gd.grabExcessHorizontalSpace = true; >- gd.horizontalAlignment = SWT.FILL; >- gd.horizontalSpan = 2; >- _errorLabel.setLayoutData(gd); >- } >- >- private void addOperation() >- { >- CapabilityDomain capabilityDomain = _editor.getCapabilityDomain(); >- NewOperationDialog dlg = new NewOperationDialog(getForm().getShell(), >- Messages.ADD_OPERATION, capabilityDomain); >- int choice = dlg.open(); >- if (choice == Window.OK) >- { >- Operation operation = dlg.getOperation(); >- AddOperationCommand command_1 = new AddOperationCommand( >- capabilityDomain, operation); >- command_1.execute(); >- operation = command_1.getOperation(); >- >- // Change the return type of new operation >- DataType returnType = dlg.getReturnType(); >- ChangeOperationReturnTypeCommand command_2 = new ChangeOperationReturnTypeCommand( >- operation, returnType); >- command_2.execute(); >- >- // Change the types of input parameters >- java.util.List paramList = dlg.getInputParams(); >- for(int i=0;i<paramList.size();i++) >- { >- InputParameter param = (InputParameter) paramList.get(i); >- ChangeInputParamTypeCommand command = new ChangeInputParamTypeCommand(param, param.getDataType()); >- command.execute(); >- } >+ } > >- _selectedOperation = operation; >- _page.setDirty(); >+ /** >+ * Handle viewer selection changed. >+ */ >+ public void selectionChanged(SelectionChangedEvent event) >+ { > } >- } > >- private void removeOperation() >- { >- CapabilityDomain capabilityDomain = _editor.getCapabilityDomain(); >- RemoveOperationCommand command = new RemoveOperationCommand( >- capabilityDomain, _selectedOperation); >- command.execute(); >- _selectedOperation = null; >- _page.setDirty(); >- } >- >- /** >- * Refreshes the section. >- */ >- public void refresh() >- { >- Capability capability = _editor.getCapabilityDomain().getCapability(); >- List operations = capability.getOperations(); >- _operationsViewer.setInput(operations); >- if (operations.size() != 0 && _selectedOperation != null) >- { >- _page.enableSections(true); >- setFocusToOperation(_selectedOperation); >- } >- else >- { >- _page.enableSections(false); >- } >- updateErrorMessage(); >- } >- >- private void updateErrorMessage() >- { >- Definition defintion = _editor.getCapabilityDomain().getDefinition(); >- CapabilityWSDLValidator validator = new CapabilityWSDLValidator(); >- IValidationReport report = validator.validate(defintion); >- boolean hasProblem = report.hasErrors() || report.hasWarnings(); >- if (hasProblem) >- { >- // We have a problem, is it an error or just a warning? >- boolean hasError = false; >- String msg; >- if (report.hasErrors()) >- { >- hasError = true; >- msg = report.getErrorMessages()[0].getMessage(); >- } >- else >- { >- msg = report.getWarningMessages()[0].getMessage(); >- } >- _errorLabel.setBackground(getForm().getDisplay().getSystemColor( >- hasError ? SWT.COLOR_RED : SWT.COLOR_YELLOW)); >- _errorLabel.setForeground(getForm().getDisplay().getSystemColor( >- hasError ? SWT.COLOR_WHITE : SWT.COLOR_BLACK)); >- _errorLabel.setText(" " + msg + " "); >- } >- else >- { >- _errorLabel.setBackground(getForm().getBackground()); >- _errorLabel.setForeground(getForm().getForeground()); >- _errorLabel.setText(""); >- } >- } >- >- /** >- * Handle double click. >- */ >- public void handleDoubleClick() >- { >- } >- >- /** >- * Handle selection changed. >- */ >- public void handleSelectionChanged(SelectionChangedEvent event) >- { >- Object[] objects = _operationsViewer.getSelectedObjets(); >- _removeOperationButton.setEnabled(objects.length > 0 && !_editor.isReadOnly()); >- if (objects.length > 0) >- { >- _selectedOperation = (Operation) objects[0]; >- _page.enableSections(true); >- List sections = _page.getSections(); >- for (int i = 0; i < sections.size(); i++) >- { >- IPageSection section = (IPageSection) sections.get(i); >- section.setSelectedObject(_selectedOperation); >- section.selectionChanged(event); >- } >- } >- } >- >- /** >- * Initialized control listeners. >- */ >- public void hookAllListeners() >- { >- getForm().addControlListener(new ControlAdapter() { >- public void controlResized(ControlEvent e) { >- Rectangle formBounds = getForm().getClientArea(); >- Rectangle sectionClientBounds = _sectionClient.getClientArea(); >- Rectangle buttonCompositeBounds = _buttonClient.getClientArea(); >- int width = sectionClientBounds.width-buttonCompositeBounds.width-20; >- int height = Math.min(formBounds.height, sectionClientBounds.height)-100; >- Table table = (Table) _operationsViewer.getControl(); >- table.setSize(width,height); >- } >- }); >- } >- >- /** >- * Handle viewer selection changed. >- */ >- public void selectionChanged(SelectionChangedEvent event) >- { >- } >- >- /** >- * Update its selected object. >- */ >- public void setSelectedObject(Object object) >- { >- if (object instanceof Operation) >- this._selectedOperation = (Operation) object; >- } >- >- private void setFocusToOperation(Operation operation) >- { >- _selectedOperation = operation; >- _operationsViewer.setSelection(new StructuredSelection(operation), >- false); >- } >- >- /** >- * Enable or disable the section based on parameter passed. >- */ >- public void enable(boolean enabled) >- { >- } >+ /** >+ * Update its selected object. >+ */ >+ public void setSelectedObject(Object object) >+ { >+ if (object instanceof Operation) >+ this._selectedOperation = (Operation) object; >+ } >+ >+ private void setFocusToOperation(Operation operation) >+ { >+ _selectedOperation = operation; >+ _operationsViewer.setSelection(new StructuredSelection(operation), >+ false); >+ } >+ >+ /** >+ * Enable or disable the section based on parameter passed. >+ */ >+ public void enable(boolean enabled) >+ { >+ } > > } > > class OperationContentProvider implements IStructuredContentProvider > { > >- public Object[] getElements(Object inputElement) >- { >- if (inputElement instanceof Collection) >- { >- Collection c = (Collection) inputElement; >- return c.toArray(); >- } >- return new Object[0]; >- } >- >- public void dispose() >- { >- } >- >- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) >- { >- } >+ public Object[] getElements(Object inputElement) >+ { >+ if (inputElement instanceof Collection) >+ { >+ Collection c = (Collection) inputElement; >+ return c.toArray(); >+ } >+ return new Object[0]; >+ } >+ >+ public void dispose() >+ { >+ } >+ >+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) >+ { >+ } > } > > class OperationLabelProvider extends LabelProvider > { > >- private final static String OPERATION_KEY = "Operation"; >+ private final static String OPERATION_KEY = "Operation"; > >- private ImageRegistry imageRegistry; >+ private ImageRegistry imageRegistry; > >- public OperationLabelProvider(Shell shell) >- { >- imageRegistry = new ImageRegistry(shell.getDisplay()); >+ public OperationLabelProvider(Shell shell) >+ { >+ imageRegistry = new ImageRegistry(shell.getDisplay()); > >- Image imgOp = EclipseUtils.loadImage(shell.getDisplay(), >- "icons/obj16/userOperation_obj.gif"); >- imageRegistry.put(OPERATION_KEY, imgOp); >+ Image imgOp = EclipseUtils.loadImage(shell.getDisplay(), >+ "icons/obj16/userOperation_obj.gif"); >+ imageRegistry.put(OPERATION_KEY, imgOp); > >- } >+ } > >- public Image getImage(Object element) >- { >- if (element instanceof Operation) >- return imageRegistry.get(OPERATION_KEY); >- return null; >- } >+ public Image getImage(Object element) >+ { >+ if (element instanceof Operation) >+ return imageRegistry.get(OPERATION_KEY); >+ return null; >+ } > >- public String getText(Object element) >- { >- if (element instanceof Operation) >+ public String getText(Object element) > { >- Operation operation = (Operation) element; >- return operation.getName(); >+ if (element instanceof Operation) >+ { >+ Operation operation = (Operation) element; >+ return operation.getName(); >+ } >+ return null; > } >- return null; >- } > } >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/operation/internal/NewExceptionDialog.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.editor.capability/src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/operation/internal/NewExceptionDialog.java,v >retrieving revision 1.4 >diff -u -r1.4 NewExceptionDialog.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/operation/internal/NewExceptionDialog.java 9 Jan 2007 19:51:43 -0000 1.4 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/operation/internal/NewExceptionDialog.java 20 Jan 2007 13:33:36 -0000 >@@ -52,231 +52,233 @@ > /** > * > * Popup dialog to add a new exception to an operation. >- * >+ * > */ > > public class NewExceptionDialog extends Dialog > { > >- private final String _title; >+ private final String _title; > >- private Table _faultsTable; >+ private Table _faultsTable; > >- private TableViewer _faultsViewer; >+ private TableViewer _faultsViewer; > >- private CapabilityDomain _capabilityDomain; >+ private CapabilityDomain _capabilityDomain; > >- private Operation _operation; >- >- private Label _errorImage; >- >- private Label _errorLabel; >- >- private Fault _fault; >- >- /** >- * Creates a new instance of this class. >- * >- * @param parentShell >- * Shell. >- * >- * @param dialogTitle >- * Title of this dialog. >- * >- * @param capabilityDomain >- * Capability domain of capability editor. >- * >- * @param operation >- * WSDL operation to which this new fault will be added. >- */ >- public NewExceptionDialog(Shell parentShell, String dialogTitle, >- CapabilityDomain capabilityDomain, Operation operation) >- { >- super(parentShell); >- setShellStyle(getShellStyle() | SWT.RESIZE); >- _title = dialogTitle; >- _capabilityDomain = capabilityDomain; >- _operation = operation; >- } >- >- protected void configureShell(Shell shell) >- { >- super.configureShell(shell); >- if (_title != null) >- shell.setText(_title); >- } >- >- protected Control createDialogArea(Composite parent) >- { >- Composite composite = (Composite) super.createDialogArea(parent); >- GridLayout layout = new GridLayout(); >- layout.numColumns = 2; >- composite.setLayout(layout); >- >- Label exceptionTypeLabel = new Label(composite, SWT.NONE); >- exceptionTypeLabel.setText(Messages.EXCPETION_TYPE_TYPE); >- GridData gd = new GridData(); >- gd.horizontalSpan = 2; >- exceptionTypeLabel.setLayoutData(gd); >- >- _faultsTable = new Table(composite, SWT.V_SCROLL | SWT.H_SCROLL >- | SWT.FULL_SELECTION); >- _faultsViewer = new TableViewer(_faultsTable); >- gd = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL); >- gd.heightHint = 225; >- gd.widthHint = 200; >- gd.horizontalSpan = ((GridLayout) composite.getLayout()).numColumns; >- >- TableColumn column = new TableColumn(_faultsTable, SWT.NONE, 0); >- column.setText(""); >- column.setWidth(20); >- column.setResizable(false); >- >- column = new TableColumn(_faultsTable, SWT.NONE, 1); >- column.setText(Messages.EXCPETION_TYPE); >- column.setWidth(100); >- >- _faultsTable.redraw(); >- _faultsTable.setHeaderVisible(true); >- _faultsTable.setLinesVisible(true); >- >- _faultsViewer.getControl().setLayoutData(gd); >- _faultsViewer.setContentProvider(new ExceptionContentProvider()); >- _faultsViewer.setLabelProvider(new ExceptionLabelProvider()); >- _faultsViewer >- .addSelectionChangedListener(new ISelectionChangedListener() >+ private Operation _operation; >+ >+ private Label _errorImage; >+ >+ private Label _errorLabel; >+ >+ private Fault _fault; >+ >+ /** >+ * Creates a new instance of this class. >+ * >+ * @param parentShell >+ * Shell. >+ * >+ * @param dialogTitle >+ * Title of this dialog. >+ * >+ * @param capabilityDomain >+ * Capability domain of capability editor. >+ * >+ * @param operation >+ * WSDL operation to which this new fault will be added. >+ */ >+ public NewExceptionDialog(Shell parentShell, String dialogTitle, >+ CapabilityDomain capabilityDomain, Operation operation) >+ { >+ super(parentShell); >+ setShellStyle(getShellStyle() | SWT.RESIZE); >+ _title = dialogTitle; >+ _capabilityDomain = capabilityDomain; >+ _operation = operation; >+ } >+ >+ protected void configureShell(Shell shell) >+ { >+ super.configureShell(shell); >+ if (_title != null) >+ shell.setText(_title); >+ } >+ >+ protected Control createDialogArea(Composite parent) >+ { >+ Composite composite = (Composite) super.createDialogArea(parent); >+ GridLayout layout = new GridLayout(); >+ layout.numColumns = 2; >+ composite.setLayout(layout); >+ >+ Label exceptionTypeLabel = new Label(composite, SWT.NONE); >+ exceptionTypeLabel.setText(Messages.EXCPETION_TYPE_TYPE); >+ GridData gd = new GridData(); >+ gd.horizontalSpan = 2; >+ exceptionTypeLabel.setLayoutData(gd); >+ >+ _faultsTable = new Table(composite, SWT.V_SCROLL | SWT.H_SCROLL >+ | SWT.FULL_SELECTION); >+ _faultsViewer = new TableViewer(_faultsTable); >+ gd = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL); >+ gd.heightHint = 225; >+ gd.widthHint = 200; >+ gd.horizontalSpan = ((GridLayout) composite.getLayout()).numColumns; >+ >+ TableColumn column = new TableColumn(_faultsTable, SWT.NONE, 0); >+ column.setText(""); >+ column.setWidth(20); >+ column.setResizable(false); >+ >+ column = new TableColumn(_faultsTable, SWT.NONE, 1); >+ column.setText(Messages.EXCPETION_TYPE); >+ column.setWidth(100); >+ >+ _faultsTable.redraw(); >+ _faultsTable.setHeaderVisible(true); >+ _faultsTable.setLinesVisible(true); >+ >+ _faultsViewer.getControl().setLayoutData(gd); >+ _faultsViewer.setContentProvider(new ExceptionContentProvider()); >+ _faultsViewer.setLabelProvider(new ExceptionLabelProvider()); >+ _faultsViewer >+ .addSelectionChangedListener(new ISelectionChangedListener() { >+ public void selectionChanged(SelectionChangedEvent event) >+ { >+ getButton(IDialogConstants.OK_ID).setEnabled(true); >+ } >+ }); >+ >+ _errorImage = new Label(composite, SWT.NONE); >+ _errorLabel = new Label(composite, SWT.NONE); >+ >+ hookAllListeners(); >+ initializeControls(); >+ >+ applyDialogFont(composite); >+ return composite; >+ } >+ >+ private void hookAllListeners() >+ { >+ } >+ >+ protected Control createButtonBar(Composite parent) >+ { >+ Control ret = super.createButtonBar(parent); >+ getButton(IDialogConstants.OK_ID).setEnabled(false); >+ return ret; >+ } >+ >+ private void initializeControls() >+ { >+ boolean baseFaultExists = false; >+ java.util.List faultElements = WsdlUtils >+ .getOperationFaultElements(_operation); >+ for (int i = 0; i < faultElements.size(); i++) >+ { >+ XSDElementDeclaration faultElement = (XSDElementDeclaration) faultElements >+ .get(i); >+ String type = WsdlUtils.getFaultType(faultElement); >+ if ("BaseFaultType".equals(type)) >+ baseFaultExists = true; >+ } >+ java.util.List list = new ArrayList(); >+ if (!baseFaultExists) > { >- public void selectionChanged(SelectionChangedEvent event) >- { >- getButton(IDialogConstants.OK_ID).setEnabled(true); >- } >- }); >- >- _errorImage = new Label(composite, SWT.NONE); >- _errorLabel = new Label(composite, SWT.NONE); >- >- hookAllListeners(); >- initializeControls(); >- >- applyDialogFont(composite); >- return composite; >- } >- >- private void hookAllListeners() >- { >- } >- >- protected Control createButtonBar(Composite parent) >- { >- Control ret = super.createButtonBar(parent); >- getButton(IDialogConstants.OK_ID).setEnabled(false); >- return ret; >- } >- >- private void initializeControls() >- { >- boolean baseFaultExists = false; >- java.util.List faultElements = WsdlUtils >- .getOperationFaultElements(_operation); >- for (int i = 0; i < faultElements.size(); i++) >- { >- XSDElementDeclaration faultElement = (XSDElementDeclaration) faultElements >- .get(i); >- String type = WsdlUtils.getFaultType(faultElement); >- if ("BaseFaultType".equals(type)) >- baseFaultExists = true; >- } >- java.util.List list = new ArrayList(); >- if (!baseFaultExists) >- { >- Fault baseFault = createBaseFaultFault(); >- list.add(baseFault); >- _faultsViewer.getTable().setBackground( >- getShell().getDisplay().getSystemColor(SWT.COLOR_WHITE)); >- _errorImage.setImage(null); >- _errorLabel.setText(""); >- } >- else >- { >- _faultsViewer.getTable().setBackground( >- getShell().getDisplay().getSystemColor(SWT.COLOR_GRAY)); >- Image image = getShell().getDisplay() >- .getSystemImage(SWT.ICON_ERROR); >- _errorImage.setImage(image); >- GridData gd = new GridData(); >- gd.heightHint = 12; >- gd.widthHint = 12; >- _errorImage.setLayoutData(gd); >- _errorLabel.setText(Messages.NO_ENTRIES_AVAIL_INFO_); >- } >- _faultsViewer.setInput(list); >- } >- >- private Fault createBaseFaultFault() >- { >- Definition definition = _capabilityDomain.getDefinition(); >- >- Fault fault = WSDLFactory.eINSTANCE.createFault(); >- fault.setName(_operation.getName() + "Fault"); >- fault.setEnclosingDefinition(definition); >- >- Message faultMessage = WSDLFactory.eINSTANCE.createMessage(); >- faultMessage.setQName(new QName(definition.getTargetNamespace(),_operation.getName() + "Fault")); >- faultMessage.setEnclosingDefinition(definition); >- >- Part faultPart = WSDLFactory.eINSTANCE.createPart(); >- faultPart.setName(_operation.getName() + "Fault"); >- faultPart.setEnclosingDefinition(definition); >- XSDElementDeclaration faultElement = createBaseFaultElement(); >- faultPart.setElementDeclaration(faultElement); >- faultPart.setElementName(new QName(faultElement.getTargetNamespace(), faultElement.getName())); >- >- faultMessage.addPart(faultPart); >- >- fault.setEMessage(faultMessage); >- >- return fault; >- } >- >- private XSDElementDeclaration createBaseFaultElement() >- { >- Definition definition = _capabilityDomain.getDefinition(); >- XSDSchema typesSchema = WsdlUtils.getSchema(definition, definition >- .getTargetNamespace()); >- >- XSDElementDeclaration faultElement = XSDFactory.eINSTANCE >- .createXSDElementDeclaration(); >- faultElement.setName(_operation.getName() + "Fault"); >- typesSchema.getContents().add(faultElement); >- >- XSDComplexTypeDefinition complexTypeDefinition = XSDFactory.eINSTANCE >- .createXSDComplexTypeDefinition(); >- complexTypeDefinition >- .setDerivationMethod(XSDDerivationMethod.EXTENSION_LITERAL); >- XSDSimpleTypeDefinition simpleTypeDef = XSDFactory.eINSTANCE >- .createXSDSimpleTypeDefinition(); >- simpleTypeDef.setName("BaseFaultType"); >- simpleTypeDef.setTargetNamespace(WsdmConstants.WSBF_NS); >- complexTypeDefinition.setBaseTypeDefinition(simpleTypeDef); >- >- faultElement.setAnonymousTypeDefinition(complexTypeDefinition); >- return faultElement; >- } >- >- protected void okPressed() >- { >- StructuredSelection ss = (StructuredSelection) _faultsViewer >- .getSelection(); >- _fault = (Fault) ss.toArray()[0]; >- super.okPressed(); >- } >- >- /** >- * >- * @return New wsdl fault. >- */ >- public Fault getFault() >- { >- return _fault; >- } >+ Fault baseFault = createBaseFaultFault(); >+ list.add(baseFault); >+ _faultsViewer.getTable().setBackground( >+ getShell().getDisplay().getSystemColor(SWT.COLOR_WHITE)); >+ _errorImage.setImage(null); >+ _errorLabel.setText(""); >+ } else >+ { >+ _faultsViewer.getTable().setBackground( >+ getShell().getDisplay().getSystemColor(SWT.COLOR_GRAY)); >+ Image image = getShell().getDisplay() >+ .getSystemImage(SWT.ICON_ERROR); >+ _errorImage.setImage(image); >+ GridData gd = new GridData(); >+ gd.heightHint = 12; >+ gd.widthHint = 12; >+ _errorImage.setLayoutData(gd); >+ _errorLabel.setText(Messages.NO_ENTRIES_AVAIL_INFO_); >+ } >+ _faultsViewer.setInput(list); >+ } >+ >+ private Fault createBaseFaultFault() >+ { >+ Definition definition = _capabilityDomain.getCapability() >+ .getDefinition(); >+ >+ Fault fault = WSDLFactory.eINSTANCE.createFault(); >+ fault.setName(_operation.getName() + "Fault"); >+ fault.setEnclosingDefinition(definition); >+ >+ Message faultMessage = WSDLFactory.eINSTANCE.createMessage(); >+ faultMessage.setQName(new QName(definition.getTargetNamespace(), >+ _operation.getName() + "Fault")); >+ faultMessage.setEnclosingDefinition(definition); >+ >+ Part faultPart = WSDLFactory.eINSTANCE.createPart(); >+ faultPart.setName(_operation.getName() + "Fault"); >+ faultPart.setEnclosingDefinition(definition); >+ XSDElementDeclaration faultElement = createBaseFaultElement(); >+ faultPart.setElementDeclaration(faultElement); >+ faultPart.setElementName(new QName(faultElement.getTargetNamespace(), >+ faultElement.getName())); >+ >+ faultMessage.addPart(faultPart); >+ >+ fault.setEMessage(faultMessage); >+ >+ return fault; >+ } >+ >+ private XSDElementDeclaration createBaseFaultElement() >+ { >+ Definition definition = _capabilityDomain.getCapability() >+ .getDefinition(); >+ XSDSchema typesSchema = WsdlUtils.getSchema(definition, definition >+ .getTargetNamespace()); >+ >+ XSDElementDeclaration faultElement = XSDFactory.eINSTANCE >+ .createXSDElementDeclaration(); >+ faultElement.setName(_operation.getName() + "Fault"); >+ typesSchema.getContents().add(faultElement); >+ >+ XSDComplexTypeDefinition complexTypeDefinition = XSDFactory.eINSTANCE >+ .createXSDComplexTypeDefinition(); >+ complexTypeDefinition >+ .setDerivationMethod(XSDDerivationMethod.EXTENSION_LITERAL); >+ XSDSimpleTypeDefinition simpleTypeDef = XSDFactory.eINSTANCE >+ .createXSDSimpleTypeDefinition(); >+ simpleTypeDef.setName("BaseFaultType"); >+ simpleTypeDef.setTargetNamespace(WsdmConstants.WSBF_NS); >+ complexTypeDefinition.setBaseTypeDefinition(simpleTypeDef); >+ >+ faultElement.setAnonymousTypeDefinition(complexTypeDefinition); >+ return faultElement; >+ } >+ >+ protected void okPressed() >+ { >+ StructuredSelection ss = (StructuredSelection) _faultsViewer >+ .getSelection(); >+ _fault = (Fault) ss.toArray()[0]; >+ super.okPressed(); >+ } >+ >+ /** >+ * >+ * @return New wsdl fault. >+ */ >+ public Fault getFault() >+ { >+ return _fault; >+ } > } >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/operation/internal/NewOperationDialog.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.editor.capability/src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/operation/internal/NewOperationDialog.java,v >retrieving revision 1.10 >diff -u -r1.10 NewOperationDialog.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/operation/internal/NewOperationDialog.java 9 Jan 2007 19:51:43 -0000 1.10 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/operation/internal/NewOperationDialog.java 20 Jan 2007 13:33:37 -0000 >@@ -13,7 +13,6 @@ > package org.eclipse.tptp.wsdm.tooling.editor.capability.pages.operation.internal; > > import java.util.Arrays; >-import java.util.Collection; > import java.util.LinkedList; > > import javax.xml.namespace.QName; >@@ -22,23 +21,17 @@ > import org.eclipse.jface.dialogs.IDialogConstants; > import org.eclipse.jface.dialogs.MessageDialog; > import org.eclipse.jface.viewers.ColumnWeightData; >-import org.eclipse.jface.viewers.IBaseLabelProvider; > import org.eclipse.jface.viewers.ISelection; > import org.eclipse.jface.viewers.ISelectionChangedListener; >-import org.eclipse.jface.viewers.IStructuredContentProvider; >-import org.eclipse.jface.viewers.ITableLabelProvider; >-import org.eclipse.jface.viewers.LabelProvider; > import org.eclipse.jface.viewers.SelectionChangedEvent; > import org.eclipse.jface.viewers.StructuredSelection; > import org.eclipse.jface.viewers.TableLayout; > import org.eclipse.jface.viewers.TableViewer; > import org.eclipse.jface.viewers.TreeViewer; >-import org.eclipse.jface.viewers.Viewer; > import org.eclipse.jface.window.Window; > import org.eclipse.swt.SWT; > import org.eclipse.swt.events.ModifyEvent; > import org.eclipse.swt.events.ModifyListener; >-import org.eclipse.swt.graphics.Image; > import org.eclipse.swt.layout.GridData; > import org.eclipse.swt.layout.GridLayout; > import org.eclipse.swt.widgets.Button; >@@ -61,7 +54,6 @@ > 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; >-import org.eclipse.tptp.wsdm.tooling.util.internal.ResourcePropertiesProvider; > import org.eclipse.tptp.wsdm.tooling.util.internal.WsdlUtils; > import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmConstants; > import org.eclipse.tptp.wsdm.tooling.util.internal.XsdUtils; >@@ -79,612 +71,624 @@ > import org.eclipse.xsd.XSDDerivationMethod; > import org.eclipse.xsd.XSDElementDeclaration; > import org.eclipse.xsd.XSDFactory; >-import org.eclipse.xsd.XSDFeature; > import org.eclipse.xsd.XSDModelGroup; > import org.eclipse.xsd.XSDParticle; > import org.eclipse.xsd.XSDSchema; > import org.eclipse.xsd.XSDSimpleTypeDefinition; > > /** >- * Popup dialog to create new operation in capability. >+ * Popup dialog to create new operation in capability. > * > */ > >-public class NewOperationDialog extends Dialog >-{ >+public class NewOperationDialog extends Dialog { > >- private final String _title; >+ private final String _title; > >- private Text _methodName; >+ private Text _methodName; > >- private TreeViewer _dataTypeViewer; >- >- private Button _importTypeButton; >- >- private Table _parametersTable; >- >- private TableViewer _paramViewer; >- >- private Button _addParameterButton; >- >- private Button _editParameterButton; >- >- private Button _removeParameterButton; >- >- private Operation _operation; >- >- private final String DEFAULT_OPERATION_NAME = "foo"; >- >- private XSDSchema _typesSchema; >- >- private Definition _definition; >- >- private java.util.List _paramList = new LinkedList(); >- >- private Capability _model; >- >- private CapabilityDomain _capabilityDomain; >- >- private static final String BASE_FAULT_FILE = "platform:/plugin/org.apache.muse.tools/artifacts/managementCapabilities/WS-BaseFaults-1_2.xsd"; >- >- private DataType _returnType; >- >- /** >- * Creates a new instance of this class. >- * >- * @param parentShell >- * Shell. >- * >- * @param dialogTitle >- * Title of this dialog. >- * >- * @param capabilityDomain >- * Capability domain of capability editor. >- * >- */ >- public NewOperationDialog(Shell parentShell, String dialogTitle, >- CapabilityDomain capabilityDomain) >- { >- super(parentShell); >- setShellStyle(getShellStyle() | SWT.RESIZE); >- _title = dialogTitle; >- _definition = capabilityDomain.getDefinition(); >- _model = capabilityDomain.getCapability(); >- _capabilityDomain = capabilityDomain; >- _operation = WSDLFactory.eINSTANCE.createOperation(); >- _operation.setName(DEFAULT_OPERATION_NAME); >- } >- >- protected void configureShell(Shell shell) >- { >- super.configureShell(shell); >- if (_title != null) >- shell.setText(_title); >- } >- >- protected Control createDialogArea(Composite parent) >- { >- Composite container = (Composite) super.createDialogArea(parent); >- GridLayout layout = new GridLayout(2, true); >- container.setLayout(layout); >- >- Composite lhsComposite = new Composite(container, SWT.NONE); >- layout = new GridLayout(2, false); >- layout.verticalSpacing = 5; >- lhsComposite.setLayout(layout); >- GridData gd = new GridData(); >- gd.grabExcessHorizontalSpace = true; >- lhsComposite.setLayoutData(gd); >- >- Composite rhsComposite = new Composite(container, SWT.NONE); >- layout = new GridLayout(); >- layout.verticalSpacing = 5; >- rhsComposite.setLayout(layout); >- gd = new GridData(); >- gd.grabExcessHorizontalSpace = true; >- rhsComposite.setLayoutData(gd); >- >- createLeftCompositeArea(lhsComposite); >- createRightCompositeArea(rhsComposite); >- >- initializeControls(); >- hookAllListeners(); >- >- applyDialogFont(container); >- return container; >- } >- >- private void createLeftCompositeArea(Composite lhsComposite) >- { >- Label methodNameLabel = new Label(lhsComposite, SWT.NONE); >- methodNameLabel.setText(Messages.OP_NAME); >- GridData gd = new GridData(); >- gd.horizontalSpan = ((GridLayout) lhsComposite.getLayout()).numColumns; >- methodNameLabel.setLayoutData(gd); >- >- _methodName = new Text(lhsComposite, SWT.SINGLE | SWT.BORDER); >- gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); >- gd.horizontalSpan = ((GridLayout) lhsComposite.getLayout()).numColumns; >- _methodName.setLayoutData(gd); >- >- Label returnTypeLabel = new Label(lhsComposite, SWT.NONE); >- returnTypeLabel.setText(Messages.OP_RETURN_TYPE); >- gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); >- gd.horizontalSpan = ((GridLayout) lhsComposite.getLayout()).numColumns; >- returnTypeLabel.setLayoutData(gd); >- >- _dataTypeViewer = new TreeViewer(lhsComposite, SWT.BORDER | SWT.H_SCROLL >- | SWT.V_SCROLL); >- GridData data = new GridData(); >- data.horizontalSpan = ((GridLayout) lhsComposite.getLayout()).numColumns; >- data.heightHint = 220; >- data.widthHint = 200; >- data.grabExcessHorizontalSpace = true; >- data.grabExcessVerticalSpace = true; >- _dataTypeViewer.getControl().setLayoutData(data); >- DataTypesContentProvider contentProvider = new DataTypesContentProvider(); >- _dataTypeViewer.setContentProvider(contentProvider); >- _dataTypeViewer.setLabelProvider(contentProvider.getLabelProvider()); >- _dataTypeViewer.getControl().setData(FormToolkit.KEY_DRAW_BORDER, >- FormToolkit.TREE_BORDER); >- >- _importTypeButton = new Button(lhsComposite, SWT.PUSH); >- _importTypeButton.setText(org.eclipse.tptp.wsdm.tooling.nls.messages.capability.internal.Messages.IMPORT_COMPLEX_DATA_TYPE); >- data = new GridData(); >- data.horizontalSpan = ((GridLayout) lhsComposite.getLayout()).numColumns; >- _importTypeButton.setLayoutData(data); >- } >- >- private void createRightCompositeArea(Composite rhsComposite) >- { >- Label parametersLabel = new Label(rhsComposite, SWT.NONE); >- parametersLabel.setText(Messages.PARAMETERS); >- GridData data = new GridData(); >- data.horizontalSpan = ((GridLayout) rhsComposite.getLayout()).numColumns; >- parametersLabel.setLayoutData(data); >- >- _parametersTable = new Table(rhsComposite, SWT.V_SCROLL | SWT.H_SCROLL >- | SWT.FULL_SELECTION); >- _paramViewer = new TableViewer(_parametersTable); >- GridData gd = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL); >- gd = new GridData(); >- gd.heightHint = 225; >- gd.widthHint = 200; >- gd.horizontalSpan = ((GridLayout) rhsComposite.getLayout()).numColumns; >- _paramViewer.getControl().setLayoutData(gd); >- >- String[] header = new String[] { Messages.PARAM_NAME, Messages.PARAM_TYPE }; >- for (int i = 0; i < header.length; i++) >- { >- TableColumn col = new TableColumn(_paramViewer.getTable(), >- SWT.CENTER); >- col.setText(header[i]); >- col.setWidth(50); >- } >- >- TableLayout tl = new TableLayout(); >- tl.addColumnData(new ColumnWeightData(50)); >- tl.addColumnData(new ColumnWeightData(50)); >- _paramViewer.getTable().setLayout(tl); >- >- _paramViewer.getTable().setHeaderVisible(true); >- _paramViewer.getTable().setLinesVisible(true); >- >- _paramViewer.setContentProvider(new ParamContentProvider()); >- _paramViewer.setLabelProvider(new ParamLabelProvider()); >- >- Composite paramButtonComposite = new Composite(rhsComposite, SWT.NULL); >- GridLayout layout = new GridLayout(3, false); >- layout.marginWidth = 0; >- paramButtonComposite.setLayout(layout); >- >- _addParameterButton = new Button(paramButtonComposite, SWT.PUSH); >- _addParameterButton.setText(org.eclipse.tptp.wsdm.tooling.nls.messages.capability.internal.Messages.ADD_BUTTON_LABEL); >- >- _editParameterButton = new Button(paramButtonComposite, SWT.PUSH); >- _editParameterButton.setText(org.eclipse.tptp.wsdm.tooling.nls.messages.capability.internal.Messages.EDIT_BUTTON_LABEL); >- >- _removeParameterButton = new Button(paramButtonComposite, SWT.PUSH); >- _removeParameterButton.setText(org.eclipse.tptp.wsdm.tooling.nls.messages.capability.internal.Messages.REMOVE_BUTTON_LABEL); >- } >- >- /** >- * >- * @return New operation. >- */ >- public Operation getOperation() >- { >- return _operation; >- } >- >- /** >- * >- * @return Data type for operation return type. >- */ >- public DataType getReturnType() >- { >- return _returnType; >- } >- >- /** >- * >- * @return Input parameter for operation. >- */ >- public java.util.List getInputParams() >- { >- return _paramList; >- } >- >- private void hookAllListeners() >- { >- _methodName.addModifyListener(new ModifyListener() >- { >- public void modifyText(ModifyEvent e) >- { >- getButton(IDialogConstants.OK_ID).setEnabled( >- !_methodName.getText().trim().equals("")); >- } >- }); >- _dataTypeViewer.addSelectionChangedListener(new ISelectionChangedListener(){ >- public void selectionChanged(SelectionChangedEvent event) { >- getButton(IDialogConstants.OK_ID).setEnabled(getSelectedViewerObject() instanceof DataType); >- }}); >- _importTypeButton.addListener(SWT.Selection, new Listener() >- { >- public void handleEvent(Event event) >- { >- importComplexTypes(); >- } >- }); >- _addParameterButton.addListener(SWT.Selection, new Listener() >- { >- public void handleEvent(Event event) >- { >- addParameter(); >- } >- }); >- _editParameterButton.addListener(SWT.Selection, new Listener() >- { >- public void handleEvent(Event event) >- { >- editParameter(); >- } >- }); >- _removeParameterButton.addListener(SWT.Selection, new Listener() >- { >- public void handleEvent(Event event) >- { >- removeParameter(); >- } >- }); >- _paramViewer.addSelectionChangedListener(new ISelectionChangedListener() >- { >- public void selectionChanged(SelectionChangedEvent event) >- { >- ISelection selection = event.getSelection(); >- _editParameterButton.setEnabled(!selection.isEmpty()); >- _removeParameterButton.setEnabled(!selection.isEmpty()); >- } >- }); >- } >- >- private void importComplexTypes() >- { >- ImportComplexTypeAction action = new ImportComplexTypeAction(getShell()); >- action.run(); >- >- _dataTypeViewer.refresh(); >- >- DataTypesCollection instance = DataTypesCollection.getInstance(); >- DataType stringDataType = instance.getDataType("string"); >- _dataTypeViewer.setSelection(new StructuredSelection(stringDataType), true); >- } >- >- private void addParameter() >- { >- NewParameterDialog dlg = new NewParameterDialog(getShell(), >- Messages.ADD_PARAM, _paramList, null); >- if (dlg.open() == Window.OK) >- { >- InputParameter parameter = dlg.getParameter(); >- _paramList.add(parameter); >- refreshParamTable(); >- } >- } >- >- private void editParameter() >- { >- InputParameter parameter = getSelectedParameter(); >- NewParameterDialog dlg = new NewParameterDialog(getShell(), >- Messages.EDIT_PARAM, _paramList, parameter); >- if (dlg.open() == Window.OK) >- { >- //InputParameter editedParameter = dlg.getParameter(); >- //_paramList.add(parameter); >- refreshParamTable(); >- } >- } >- >- private void removeParameter() >- { >- InputParameter parameter = getSelectedParameter(); >- _paramList.remove(parameter); >- _removeParameterButton.setEnabled(_paramList.size() != 0); >- refreshParamTable(); >- } >- >- protected Control createButtonBar(Composite parent) >- { >- Control ret = super.createButtonBar(parent); >- return ret; >- } >- >- private void refreshParamTable() >- { >- _paramViewer.setInput(_paramList); >- } >- >- private InputParameter getSelectedParameter() >- { >- ISelection selection = _paramViewer.getSelection(); >- InputParameter selectedParam = null; >- if (selection instanceof StructuredSelection) >- { >- StructuredSelection ss = (StructuredSelection) selection; >- Object selected = ss.getFirstElement(); >- if (selected instanceof InputParameter) >- { >- selectedParam = (InputParameter) selected; >- } >- } >- return selectedParam; >- } >- >- private void initializeControls() >- { >- NewNameGenerator nameGenerator = new NewNameGenerator("operation"); >- String opName = nameGenerator.getNextName(); >- while (operationAlreadyExists(opName)) >- { >- opName = nameGenerator.getNextName(); >- } >- >- _methodName.setText(opName); >- >- DataTypesCollection instance = DataTypesCollection.getInstance(); >- DataTypeCategory[] categories = instance.getDataTypeCategories(); >- _dataTypeViewer.setInput(Arrays.asList(categories)); >- _dataTypeViewer.refresh(); >- DataType voidDataType = instance.getDataType("void"); >- _dataTypeViewer.setSelection(new StructuredSelection(voidDataType), true); >- >- _editParameterButton.setEnabled(false); >- _removeParameterButton.setEnabled(false); >- _methodName.setSelection(0, _methodName.getCharCount()); >- } >- >- private boolean operationAlreadyExists(String name) >- { >- if (CapUtils.getInstancesOfOperation(_model, name) >= 1) >- return true; >- return false; >- } >- >- private boolean validOperation() >- { >- // Check for valid java identifier name >- String msg = CapUtils.validateJavaIdentifier(_operation.getName()); >- if (msg != null) >- { >- MessageDialog.openError(getShell(), "ERROR", >- Messages.OP_NOT_VALID_JAVA_ID_WARN_); >- return false; >- } >- if (operationAlreadyExists(_operation.getName())) >- { >- MessageDialog.openError(getShell(), "ERROR", >- Messages.OPERATION_ALREADY_EXISTS_WARN_); >- return false; >+ private TreeViewer _dataTypeViewer; >+ >+ private Button _importTypeButton; >+ >+ private Table _parametersTable; >+ >+ private TableViewer _paramViewer; >+ >+ private Button _addParameterButton; >+ >+ private Button _editParameterButton; >+ >+ private Button _removeParameterButton; >+ >+ private Operation _operation; >+ >+ private final String DEFAULT_OPERATION_NAME = "foo"; >+ >+ private XSDSchema _typesSchema; >+ >+ private Definition _definition; >+ >+ private java.util.List _paramList = new LinkedList(); >+ >+ private Capability _model; >+ >+ private CapabilityDomain _capabilityDomain; >+ >+ private static final String BASE_FAULT_FILE = "platform:/plugin/org.apache.muse.tools/artifacts/managementCapabilities/WS-BaseFaults-1_2.xsd"; >+ >+ private DataType _returnType; >+ >+ /** >+ * Creates a new instance of this class. >+ * >+ * @param parentShell >+ * Shell. >+ * >+ * @param dialogTitle >+ * Title of this dialog. >+ * >+ * @param capabilityDomain >+ * Capability domain of capability editor. >+ * >+ */ >+ public NewOperationDialog(Shell parentShell, String dialogTitle, >+ CapabilityDomain capabilityDomain) >+ { >+ super(parentShell); >+ setShellStyle(getShellStyle() | SWT.RESIZE); >+ _title = dialogTitle; >+ _model = capabilityDomain.getCapability(); >+ _definition = _model.getDefinition(); >+ _capabilityDomain = capabilityDomain; >+ _operation = WSDLFactory.eINSTANCE.createOperation(); >+ _operation.setName(DEFAULT_OPERATION_NAME); >+ } >+ >+ protected void configureShell(Shell shell) >+ { >+ super.configureShell(shell); >+ if (_title != null) >+ shell.setText(_title); >+ } >+ >+ protected Control createDialogArea(Composite parent) >+ { >+ Composite container = (Composite) super.createDialogArea(parent); >+ GridLayout layout = new GridLayout(2, true); >+ container.setLayout(layout); >+ >+ Composite lhsComposite = new Composite(container, SWT.NONE); >+ layout = new GridLayout(2, false); >+ layout.verticalSpacing = 5; >+ lhsComposite.setLayout(layout); >+ GridData gd = new GridData(); >+ gd.grabExcessHorizontalSpace = true; >+ lhsComposite.setLayoutData(gd); >+ >+ Composite rhsComposite = new Composite(container, SWT.NONE); >+ layout = new GridLayout(); >+ layout.verticalSpacing = 5; >+ rhsComposite.setLayout(layout); >+ gd = new GridData(); >+ gd.grabExcessHorizontalSpace = true; >+ rhsComposite.setLayoutData(gd); >+ >+ createLeftCompositeArea(lhsComposite); >+ createRightCompositeArea(rhsComposite); >+ >+ initializeControls(); >+ hookAllListeners(); >+ >+ applyDialogFont(container); >+ return container; >+ } >+ >+ private void createLeftCompositeArea(Composite lhsComposite) >+ { >+ Label methodNameLabel = new Label(lhsComposite, SWT.NONE); >+ methodNameLabel.setText(Messages.OP_NAME); >+ GridData gd = new GridData(); >+ gd.horizontalSpan = ((GridLayout) lhsComposite.getLayout()).numColumns; >+ methodNameLabel.setLayoutData(gd); >+ >+ _methodName = new Text(lhsComposite, SWT.SINGLE | SWT.BORDER); >+ gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); >+ gd.horizontalSpan = ((GridLayout) lhsComposite.getLayout()).numColumns; >+ _methodName.setLayoutData(gd); >+ >+ Label returnTypeLabel = new Label(lhsComposite, SWT.NONE); >+ returnTypeLabel.setText(Messages.OP_RETURN_TYPE); >+ gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); >+ gd.horizontalSpan = ((GridLayout) lhsComposite.getLayout()).numColumns; >+ returnTypeLabel.setLayoutData(gd); >+ >+ _dataTypeViewer = new TreeViewer(lhsComposite, SWT.BORDER >+ | SWT.H_SCROLL | SWT.V_SCROLL); >+ GridData data = new GridData(); >+ data.horizontalSpan = ((GridLayout) lhsComposite.getLayout()).numColumns; >+ data.heightHint = 220; >+ data.widthHint = 200; >+ data.grabExcessHorizontalSpace = true; >+ data.grabExcessVerticalSpace = true; >+ _dataTypeViewer.getControl().setLayoutData(data); >+ DataTypesContentProvider contentProvider = new DataTypesContentProvider(); >+ _dataTypeViewer.setContentProvider(contentProvider); >+ _dataTypeViewer.setLabelProvider(contentProvider.getLabelProvider()); >+ _dataTypeViewer.getControl().setData(FormToolkit.KEY_DRAW_BORDER, >+ FormToolkit.TREE_BORDER); >+ >+ _importTypeButton = new Button(lhsComposite, SWT.PUSH); >+ _importTypeButton >+ .setText(org.eclipse.tptp.wsdm.tooling.nls.messages.capability.internal.Messages.IMPORT_COMPLEX_DATA_TYPE); >+ data = new GridData(); >+ data.horizontalSpan = ((GridLayout) lhsComposite.getLayout()).numColumns; >+ _importTypeButton.setLayoutData(data); >+ } >+ >+ private void createRightCompositeArea(Composite rhsComposite) >+ { >+ Label parametersLabel = new Label(rhsComposite, SWT.NONE); >+ parametersLabel.setText(Messages.PARAMETERS); >+ GridData data = new GridData(); >+ data.horizontalSpan = ((GridLayout) rhsComposite.getLayout()).numColumns; >+ parametersLabel.setLayoutData(data); >+ >+ _parametersTable = new Table(rhsComposite, SWT.V_SCROLL | SWT.H_SCROLL >+ | SWT.FULL_SELECTION); >+ _paramViewer = new TableViewer(_parametersTable); >+ GridData gd = new GridData(GridData.FILL_HORIZONTAL >+ | GridData.FILL_VERTICAL); >+ gd = new GridData(); >+ gd.heightHint = 225; >+ gd.widthHint = 200; >+ gd.horizontalSpan = ((GridLayout) rhsComposite.getLayout()).numColumns; >+ _paramViewer.getControl().setLayoutData(gd); >+ >+ String[] header = new String[] { Messages.PARAM_NAME, >+ Messages.PARAM_TYPE }; >+ for (int i = 0; i < header.length; i++) >+ { >+ TableColumn col = new TableColumn(_paramViewer.getTable(), >+ SWT.CENTER); >+ col.setText(header[i]); >+ col.setWidth(50); >+ } >+ >+ TableLayout tl = new TableLayout(); >+ tl.addColumnData(new ColumnWeightData(50)); >+ tl.addColumnData(new ColumnWeightData(50)); >+ _paramViewer.getTable().setLayout(tl); >+ >+ _paramViewer.getTable().setHeaderVisible(true); >+ _paramViewer.getTable().setLinesVisible(true); >+ >+ _paramViewer.setContentProvider(new ParamContentProvider()); >+ _paramViewer.setLabelProvider(new ParamLabelProvider()); >+ >+ Composite paramButtonComposite = new Composite(rhsComposite, SWT.NULL); >+ GridLayout layout = new GridLayout(3, false); >+ layout.marginWidth = 0; >+ paramButtonComposite.setLayout(layout); >+ >+ _addParameterButton = new Button(paramButtonComposite, SWT.PUSH); >+ _addParameterButton >+ .setText(org.eclipse.tptp.wsdm.tooling.nls.messages.capability.internal.Messages.ADD_BUTTON_LABEL); >+ >+ _editParameterButton = new Button(paramButtonComposite, SWT.PUSH); >+ _editParameterButton >+ .setText(org.eclipse.tptp.wsdm.tooling.nls.messages.capability.internal.Messages.EDIT_BUTTON_LABEL); >+ >+ _removeParameterButton = new Button(paramButtonComposite, SWT.PUSH); >+ _removeParameterButton >+ .setText(org.eclipse.tptp.wsdm.tooling.nls.messages.capability.internal.Messages.REMOVE_BUTTON_LABEL); >+ } >+ >+ /** >+ * >+ * @return New operation. >+ */ >+ public Operation getOperation() >+ { >+ return _operation; >+ } >+ >+ /** >+ * >+ * @return Data type for operation return type. >+ */ >+ public DataType getReturnType() >+ { >+ return _returnType; >+ } >+ >+ /** >+ * >+ * @return Input parameter for operation. >+ */ >+ public java.util.List getInputParams() >+ { >+ return _paramList; >+ } >+ >+ private void hookAllListeners() >+ { >+ _methodName.addModifyListener(new ModifyListener() >+ { >+ public void modifyText(ModifyEvent e) >+ { >+ getButton(IDialogConstants.OK_ID).setEnabled( >+ !_methodName.getText().trim().equals("")); >+ } >+ }); >+ _dataTypeViewer >+ .addSelectionChangedListener(new ISelectionChangedListener() >+ { >+ public void selectionChanged(SelectionChangedEvent event) >+ { >+ getButton(IDialogConstants.OK_ID).setEnabled( >+ getSelectedViewerObject() instanceof DataType); >+ } >+ }); >+ _importTypeButton.addListener(SWT.Selection, new Listener() >+ { >+ public void handleEvent(Event event) >+ { >+ importComplexTypes(); >+ } >+ }); >+ _addParameterButton.addListener(SWT.Selection, new Listener() >+ { >+ public void handleEvent(Event event) >+ { >+ addParameter(); >+ } >+ }); >+ _editParameterButton.addListener(SWT.Selection, new Listener() >+ { >+ public void handleEvent(Event event) >+ { >+ editParameter(); >+ } >+ }); >+ _removeParameterButton.addListener(SWT.Selection, new Listener() >+ { >+ public void handleEvent(Event event) >+ { >+ removeParameter(); >+ } >+ }); >+ _paramViewer >+ .addSelectionChangedListener(new ISelectionChangedListener() >+ { >+ public void selectionChanged(SelectionChangedEvent event) >+ { >+ ISelection selection = event.getSelection(); >+ _editParameterButton.setEnabled(!selection.isEmpty()); >+ _removeParameterButton.setEnabled(!selection.isEmpty()); >+ } >+ }); >+ } >+ >+ private void importComplexTypes() >+ { >+ ImportComplexTypeAction action = new ImportComplexTypeAction(getShell()); >+ action.run(); >+ >+ _dataTypeViewer.refresh(); >+ >+ DataTypesCollection instance = DataTypesCollection.getInstance(); >+ DataType stringDataType = instance.getDataType("string"); >+ _dataTypeViewer.setSelection(new StructuredSelection(stringDataType), >+ true); >+ } >+ >+ private void addParameter() >+ { >+ NewParameterDialog dlg = new NewParameterDialog(getShell(), >+ Messages.ADD_PARAM, _paramList, null); >+ if (dlg.open() == Window.OK) >+ { >+ InputParameter parameter = dlg.getParameter(); >+ _paramList.add(parameter); >+ refreshParamTable(); >+ } >+ } >+ >+ private void editParameter() >+ { >+ InputParameter parameter = getSelectedParameter(); >+ NewParameterDialog dlg = new NewParameterDialog(getShell(), >+ Messages.EDIT_PARAM, _paramList, parameter); >+ if (dlg.open() == Window.OK) >+ { >+ // InputParameter editedParameter = dlg.getParameter(); >+ // _paramList.add(parameter); >+ refreshParamTable(); >+ } >+ } >+ >+ private void removeParameter() >+ { >+ InputParameter parameter = getSelectedParameter(); >+ _paramList.remove(parameter); >+ _removeParameterButton.setEnabled(_paramList.size() != 0); >+ refreshParamTable(); >+ } >+ >+ protected Control createButtonBar(Composite parent) >+ { >+ Control ret = super.createButtonBar(parent); >+ return ret; >+ } >+ >+ private void refreshParamTable() >+ { >+ _paramViewer.setInput(_paramList); >+ } >+ >+ private InputParameter getSelectedParameter() >+ { >+ ISelection selection = _paramViewer.getSelection(); >+ InputParameter selectedParam = null; >+ if (selection instanceof StructuredSelection) >+ { >+ StructuredSelection ss = (StructuredSelection) selection; >+ Object selected = ss.getFirstElement(); >+ if (selected instanceof InputParameter) >+ selectedParam = (InputParameter) selected; >+ } >+ return selectedParam; >+ } >+ >+ private void initializeControls() >+ { >+ NewNameGenerator nameGenerator = new NewNameGenerator("operation"); >+ String opName = nameGenerator.getNextName(); >+ while (operationAlreadyExists(opName)) >+ opName = nameGenerator.getNextName(); >+ >+ _methodName.setText(opName); >+ >+ DataTypesCollection instance = DataTypesCollection.getInstance(); >+ DataTypeCategory[] categories = instance.getDataTypeCategories(); >+ _dataTypeViewer.setInput(Arrays.asList(categories)); >+ _dataTypeViewer.refresh(); >+ DataType voidDataType = instance.getDataType("void"); >+ _dataTypeViewer.setSelection(new StructuredSelection(voidDataType), >+ true); >+ >+ _editParameterButton.setEnabled(false); >+ _removeParameterButton.setEnabled(false); >+ _methodName.setSelection(0, _methodName.getCharCount()); > } >- if (CapUtils.isOperationNameConflicted(_operation.getName())) >+ >+ private boolean operationAlreadyExists(String name) > { >- MessageDialog.openError(getShell(), "ERROR", >- Messages.bind(Messages.CONFLICTED_OPERATION_WARN_, _operation.getName())); >+ if (CapUtils.getInstancesOfOperation(_model, name) >= 1) >+ return true; > return false; > } >- // TODO Check for operation overloading >- return true; >- } >- >- protected void okPressed() >- { >- >- _typesSchema = WsdlUtils.createOrFindSchema(_definition, _definition >- .getTargetNamespace()); >- WsdlUtils.createOrFindPrefix(_definition, WsdmConstants.WSBF_NS, "wsbf"); >- XsdUtils.createImportStatement(_typesSchema, WsdmConstants.WSBF_NS, >- getBaseFaultFileURI()); >- >- _operation.setName(_methodName.getText()); >- >- if (!validOperation()) >- { >- _methodName.setSelection(0, _methodName.getCharCount()); >- _methodName.forceFocus(); >- return; >- } >- >- _operation.setEnclosingDefinition(_definition); >- >- Input input = prepareOperationInput(); >- _operation.setEInput(input); >- >- Output output = prepareOperationOutput(); >- _operation.setEOutput(output); >- >- Fault fault = prepareOperationFault(); >- _operation.addFault(fault); >- >- super.okPressed(); >- } >- >- private String getBaseFaultFileURI() >- { >-// String containerPath = _capabilityDomain.getCapabilityFile() >-// .getLocation().toString(); >-// >-// Bundle modelPlugin = _capabilityDomain.getModelPlugin(); >-// Path BASE_FAULT_PATH = new Path(BASE_FAULT_FILE); >-// String filePath = EclipseUtils.getResolvedPath(modelPlugin, >-// BASE_FAULT_PATH); >-// filePath = EclipseUtils.replaceAll(filePath, '\\', '/'); >-// return EclipseUtils.getRelativePath(containerPath, filePath, '/'); >- return BASE_FAULT_FILE; >- } >- >- private Input prepareOperationInput() >- { >- Input input = WSDLFactory.eINSTANCE.createInput(); >- input.setEnclosingDefinition(_definition); >- input.setName(_methodName.getText() + "Request"); >- Message inputMessage = prepareInputMessage(); >- input.setMessage(inputMessage); >- return input; >- } >- >- private Output prepareOperationOutput() >- { >- Output output = WSDLFactory.eINSTANCE.createOutput(); >- output.setEnclosingDefinition(_definition); >- output.setName(_methodName.getText() + "Response"); >- Message outputMessage = prepareOutputMessage(); >- output.setMessage(outputMessage); >- return output; >- } >- >- private Fault prepareOperationFault() >- { >- Fault fault = WSDLFactory.eINSTANCE.createFault(); >- fault.setEnclosingDefinition(_definition); >- fault.setName(_methodName.getText() + "Fault"); >- Message faultMessage = prepareFaultMessage(); >- fault.setMessage(faultMessage); >- return fault; >- } >- >- private Message prepareInputMessage() >- { >- XSDElementDeclaration inputParamHolderElement = prepareInputElement(); >- String name = _methodName.getText() + "Request"; >- return prepareMessage(name, inputParamHolderElement); >- } >- >- private Message prepareOutputMessage() >- { >- XSDElementDeclaration outputElement = prepareOutputElement(); >- String name = _methodName.getText() + "Response"; >- return prepareMessage(name, outputElement); >- } >- >- private Message prepareFaultMessage() >- { >- XSDElementDeclaration faultElement = prepareFaultElement(); >- String name = _methodName.getText() + "Fault"; >- return prepareMessage(name, faultElement); >- } >- >- private Message prepareMessage(String name, >- XSDElementDeclaration elementDeclaration) >- { >- >- Part part = WSDLFactory.eINSTANCE.createPart(); >- part.setEnclosingDefinition(_definition); >- part.setName(name); >- part.setElementName(new QName(elementDeclaration.getTargetNamespace(), >- elementDeclaration.getName())); >- part.setElementDeclaration(elementDeclaration); >- //((PartImpl) part).reconcileReferences(false); >- >- Message message = WSDLFactory.eINSTANCE.createMessage(); >- message.setEnclosingDefinition(_definition); >- message.setQName(new QName(_definition.getTargetNamespace(), name)); >- message.addPart(part); >- _definition.addMessage(message); >- >- return message; >- } >- >- private XSDElementDeclaration prepareInputElement() >- { >- XSDElementDeclaration inputParamHolderElement = XSDFactory.eINSTANCE >- .createXSDElementDeclaration(); >- inputParamHolderElement.setName(_methodName.getText()); >- _typesSchema.getContents().add(inputParamHolderElement); >- if (_paramList.size() == 0) >- { >- inputParamHolderElement.setAnonymousTypeDefinition(null); >- return inputParamHolderElement; >- } >- >- XSDModelGroup 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); >- inputParamHolderElement >- .setAnonymousTypeDefinition(complexTypeDefiniton); >- inputParamHolderElement.setTypeDefinition(complexTypeDefiniton); >- >- for (int i = 0; i < _paramList.size(); i++) >- { >- InputParameter parameter = (InputParameter) _paramList.get(i); >- XSDParticle simpleElementParticle = XSDFactory.eINSTANCE >- .createXSDParticle(); >- if(parameter.isArrayType()) >- simpleElementParticle.setMaxOccurs(-1); >- simpleElementParticle.setContent(parameter.getXSDElementDeclaration()); >- modelGroup.getContents().add(simpleElementParticle); >- } >- return inputParamHolderElement; >- } >- >- private XSDElementDeclaration prepareOutputElement() >- { >- XSDElementDeclaration outputTypeElement = XSDFactory.eINSTANCE >- .createXSDElementDeclaration(); >- outputTypeElement.setName(_methodName.getText() + "Response"); >- _typesSchema.getContents().add(outputTypeElement); >- _returnType = (DataType) getSelectedViewerObject(); >- return outputTypeElement; >- } >- >- private XSDElementDeclaration prepareFaultElement() >- { >- XSDElementDeclaration faultElement = XSDFactory.eINSTANCE >- .createXSDElementDeclaration(); >- faultElement.setName(_methodName.getText() + "Fault"); >- _typesSchema.getContents().add(faultElement); >- >- XSDComplexTypeDefinition complexTypeDefinition = XSDFactory.eINSTANCE >- .createXSDComplexTypeDefinition(); >- complexTypeDefinition >- .setDerivationMethod(XSDDerivationMethod.EXTENSION_LITERAL); >- XSDSimpleTypeDefinition simpleTypeDef = XSDFactory.eINSTANCE >- .createXSDSimpleTypeDefinition(); >- simpleTypeDef.setName("BaseFaultType"); >- simpleTypeDef.setTargetNamespace(WsdmConstants.WSBF_NS); >- complexTypeDefinition.setBaseTypeDefinition(simpleTypeDef); >- >- faultElement.setAnonymousTypeDefinition(complexTypeDefinition); >- faultElement.setTypeDefinition(complexTypeDefinition); >- return faultElement; >- } >- >- private Object getSelectedViewerObject(){ >- StructuredSelection ss = (StructuredSelection) _dataTypeViewer.getSelection(); >- Object[] selectedObjects = ss.toArray(); >- return selectedObjects[0]; >- } >+ >+ private boolean validOperation() >+ { >+ // Check for valid java identifier name >+ String msg = CapUtils.validateJavaIdentifier(_operation.getName()); >+ if (msg != null) >+ { >+ MessageDialog.openError(getShell(), "ERROR", >+ Messages.OP_NOT_VALID_JAVA_ID_WARN_); >+ return false; >+ } >+ if (operationAlreadyExists(_operation.getName())) >+ { >+ MessageDialog.openError(getShell(), "ERROR", >+ Messages.OPERATION_ALREADY_EXISTS_WARN_); >+ return false; >+ } >+ if (CapUtils.isOperationNameConflicted(_operation.getName())) >+ { >+ MessageDialog.openError(getShell(), "ERROR", Messages.bind( >+ Messages.CONFLICTED_OPERATION_WARN_, _operation.getName())); >+ return false; >+ } >+ // TODO Check for operation overloading >+ return true; >+ } >+ >+ protected void okPressed() >+ { >+ >+ _typesSchema = WsdlUtils.createOrFindSchema(_definition, _definition >+ .getTargetNamespace()); >+ WsdlUtils >+ .createOrFindPrefix(_definition, WsdmConstants.WSBF_NS, "wsbf"); >+ XsdUtils.createImportStatement(_typesSchema, WsdmConstants.WSBF_NS, >+ getBaseFaultFileURI()); >+ >+ _operation.setName(_methodName.getText()); >+ >+ if (!validOperation()) >+ { >+ _methodName.setSelection(0, _methodName.getCharCount()); >+ _methodName.forceFocus(); >+ return; >+ } >+ >+ _operation.setEnclosingDefinition(_definition); >+ >+ Input input = prepareOperationInput(); >+ _operation.setEInput(input); >+ >+ Output output = prepareOperationOutput(); >+ _operation.setEOutput(output); >+ >+ Fault fault = prepareOperationFault(); >+ _operation.addFault(fault); >+ >+ super.okPressed(); >+ } >+ >+ private String getBaseFaultFileURI() >+ { >+ // String containerPath = _capabilityDomain.getCapabilityFile() >+ // .getLocation().toString(); >+ // >+ // Bundle modelPlugin = _capabilityDomain.getModelPlugin(); >+ // Path BASE_FAULT_PATH = new Path(BASE_FAULT_FILE); >+ // String filePath = EclipseUtils.getResolvedPath(modelPlugin, >+ // BASE_FAULT_PATH); >+ // filePath = EclipseUtils.replaceAll(filePath, '\\', '/'); >+ // return EclipseUtils.getRelativePath(containerPath, filePath, '/'); >+ return BASE_FAULT_FILE; >+ } >+ >+ private Input prepareOperationInput() >+ { >+ Input input = WSDLFactory.eINSTANCE.createInput(); >+ input.setEnclosingDefinition(_definition); >+ input.setName(_methodName.getText() + "Request"); >+ Message inputMessage = prepareInputMessage(); >+ input.setMessage(inputMessage); >+ return input; >+ } >+ >+ private Output prepareOperationOutput() >+ { >+ Output output = WSDLFactory.eINSTANCE.createOutput(); >+ output.setEnclosingDefinition(_definition); >+ output.setName(_methodName.getText() + "Response"); >+ Message outputMessage = prepareOutputMessage(); >+ output.setMessage(outputMessage); >+ return output; >+ } >+ >+ private Fault prepareOperationFault() >+ { >+ Fault fault = WSDLFactory.eINSTANCE.createFault(); >+ fault.setEnclosingDefinition(_definition); >+ fault.setName(_methodName.getText() + "Fault"); >+ Message faultMessage = prepareFaultMessage(); >+ fault.setMessage(faultMessage); >+ return fault; >+ } >+ >+ private Message prepareInputMessage() >+ { >+ XSDElementDeclaration inputParamHolderElement = prepareInputElement(); >+ String name = _methodName.getText() + "Request"; >+ return prepareMessage(name, inputParamHolderElement); >+ } >+ >+ private Message prepareOutputMessage() >+ { >+ XSDElementDeclaration outputElement = prepareOutputElement(); >+ String name = _methodName.getText() + "Response"; >+ return prepareMessage(name, outputElement); >+ } >+ >+ private Message prepareFaultMessage() >+ { >+ XSDElementDeclaration faultElement = prepareFaultElement(); >+ String name = _methodName.getText() + "Fault"; >+ return prepareMessage(name, faultElement); >+ } >+ >+ private Message prepareMessage(String name, >+ XSDElementDeclaration elementDeclaration) >+ { >+ >+ Part part = WSDLFactory.eINSTANCE.createPart(); >+ part.setEnclosingDefinition(_definition); >+ part.setName(name); >+ part.setElementName(new QName(elementDeclaration.getTargetNamespace(), >+ elementDeclaration.getName())); >+ part.setElementDeclaration(elementDeclaration); >+ // ((PartImpl) part).reconcileReferences(false); >+ >+ Message message = WSDLFactory.eINSTANCE.createMessage(); >+ message.setEnclosingDefinition(_definition); >+ message.setQName(new QName(_definition.getTargetNamespace(), name)); >+ message.addPart(part); >+ _definition.addMessage(message); >+ >+ return message; >+ } >+ >+ private XSDElementDeclaration prepareInputElement() >+ { >+ XSDElementDeclaration inputParamHolderElement = XSDFactory.eINSTANCE >+ .createXSDElementDeclaration(); >+ inputParamHolderElement.setName(_methodName.getText()); >+ _typesSchema.getContents().add(inputParamHolderElement); >+ if (_paramList.size() == 0) >+ { >+ inputParamHolderElement.setAnonymousTypeDefinition(null); >+ return inputParamHolderElement; >+ } >+ >+ XSDModelGroup 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); >+ inputParamHolderElement >+ .setAnonymousTypeDefinition(complexTypeDefiniton); >+ inputParamHolderElement.setTypeDefinition(complexTypeDefiniton); >+ >+ for (int i = 0; i < _paramList.size(); i++) >+ { >+ InputParameter parameter = (InputParameter) _paramList.get(i); >+ XSDParticle simpleElementParticle = XSDFactory.eINSTANCE >+ .createXSDParticle(); >+ if (parameter.isArrayType()) >+ simpleElementParticle.setMaxOccurs(-1); >+ simpleElementParticle.setContent(parameter >+ .getXSDElementDeclaration()); >+ modelGroup.getContents().add(simpleElementParticle); >+ } >+ return inputParamHolderElement; >+ } >+ >+ private XSDElementDeclaration prepareOutputElement() >+ { >+ XSDElementDeclaration outputTypeElement = XSDFactory.eINSTANCE >+ .createXSDElementDeclaration(); >+ outputTypeElement.setName(_methodName.getText() + "Response"); >+ _typesSchema.getContents().add(outputTypeElement); >+ _returnType = (DataType) getSelectedViewerObject(); >+ return outputTypeElement; >+ } >+ >+ private XSDElementDeclaration prepareFaultElement() >+ { >+ XSDElementDeclaration faultElement = XSDFactory.eINSTANCE >+ .createXSDElementDeclaration(); >+ faultElement.setName(_methodName.getText() + "Fault"); >+ _typesSchema.getContents().add(faultElement); >+ >+ XSDComplexTypeDefinition complexTypeDefinition = XSDFactory.eINSTANCE >+ .createXSDComplexTypeDefinition(); >+ complexTypeDefinition >+ .setDerivationMethod(XSDDerivationMethod.EXTENSION_LITERAL); >+ XSDSimpleTypeDefinition simpleTypeDef = XSDFactory.eINSTANCE >+ .createXSDSimpleTypeDefinition(); >+ simpleTypeDef.setName("BaseFaultType"); >+ simpleTypeDef.setTargetNamespace(WsdmConstants.WSBF_NS); >+ complexTypeDefinition.setBaseTypeDefinition(simpleTypeDef); >+ >+ faultElement.setAnonymousTypeDefinition(complexTypeDefinition); >+ faultElement.setTypeDefinition(complexTypeDefinition); >+ return faultElement; >+ } >+ >+ private Object getSelectedViewerObject() >+ { >+ StructuredSelection ss = (StructuredSelection) _dataTypeViewer >+ .getSelection(); >+ Object[] selectedObjects = ss.toArray(); >+ return selectedObjects[0]; >+ } > } >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/operation/internal/DetailsSection.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.editor.capability/src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/operation/internal/DetailsSection.java,v >retrieving revision 1.7 >diff -u -r1.7 DetailsSection.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/operation/internal/DetailsSection.java 9 Jan 2007 19:51:44 -0000 1.7 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/operation/internal/DetailsSection.java 20 Jan 2007 13:33:35 -0000 >@@ -54,215 +54,229 @@ > public class DetailsSection extends AbstractPageSection > { > >- private Text _operationNameText; >+ private Text _operationNameText; > >- private Text _operationReturnType; >- >- private Button _changeReturnTypeButton; >- >- private Button _importTypeButton; >- >- private Operation _selectedOperation; >- >- /** >- * Creates a new object of this class. >- */ >- DetailsSection(CapabilityEditor editor, IUIPage page, ScrolledForm form, >- FormToolkit toolkit) >- { >- super(editor, page, form, toolkit); >- } >- >- /** >- * Creates the section. >- */ >- public void create() >- { >- Composite sectionClient = createSection(org.eclipse.tptp.wsdm.tooling.nls.messages.capability.internal.Messages.DETAILS_LABEL, >- Messages.DETAILS_OF_OP); >- GridLayout layout = new GridLayout(3, false); >- layout.marginWidth = LAYOUT_MARGIN_WIDTH; >- layout.verticalSpacing = LAYOUT_VERTICAL_SPACING; >- layout.horizontalSpacing = LAYOUT_HORIZONTAL_SPACING; >- sectionClient.setLayout(layout); >- FormToolkit toolkit = getToolkit(); >- >- Label operationNameLabel = toolkit.createLabel(sectionClient, >- Messages.OP_NAME); >- GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, SWT.NONE, false, false); >- operationNameLabel.setLayoutData(gd); >- >- _operationNameText = toolkit.createText(sectionClient, "", SWT.SINGLE >- | SWT.BORDER); >- gd = new GridData(SWT.FILL, SWT.NONE, true, false); >- gd.minimumWidth = SWT.DEFAULT; >- gd.horizontalSpan = 2; >- _operationNameText.setLayoutData(gd); >- >- Label operationReturnTypeLabel = toolkit.createLabel(sectionClient, >- Messages.OP_RETURN_TYPE); >- gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, SWT.NONE, false, false); >- operationReturnTypeLabel.setLayoutData(gd); >- >- _operationReturnType = new Text(sectionClient, SWT.SINGLE | SWT.BORDER); >- gd = new GridData(SWT.FILL, SWT.NONE, true, false); >- _operationReturnType.setLayoutData(gd); >- _operationReturnType.setEditable(false); >- >- _changeReturnTypeButton = createPushButton(sectionClient, toolkit, >- org.eclipse.tptp.wsdm.tooling.nls.messages.capability.internal.Messages.CHANGE_BUTTON_LABEL, >- new Listener() >+ private Text _operationReturnType; >+ >+ private Button _changeReturnTypeButton; >+ >+ private Button _importTypeButton; >+ >+ private Operation _selectedOperation; >+ >+ /** >+ * Creates a new object of this class. >+ */ >+ DetailsSection(CapabilityEditor editor, IUIPage page, ScrolledForm form, >+ FormToolkit toolkit) >+ { >+ super(editor, page, form, toolkit); >+ } >+ >+ /** >+ * Creates the section. >+ */ >+ public void create() >+ { >+ Composite sectionClient = createSection( >+ org.eclipse.tptp.wsdm.tooling.nls.messages.capability.internal.Messages.DETAILS_LABEL, >+ Messages.DETAILS_OF_OP); >+ GridLayout layout = new GridLayout(3, false); >+ layout.marginWidth = LAYOUT_MARGIN_WIDTH; >+ layout.verticalSpacing = LAYOUT_VERTICAL_SPACING; >+ layout.horizontalSpacing = LAYOUT_HORIZONTAL_SPACING; >+ sectionClient.setLayout(layout); >+ FormToolkit toolkit = getToolkit(); >+ >+ Label operationNameLabel = toolkit.createLabel(sectionClient, >+ Messages.OP_NAME); >+ GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, >+ SWT.NONE, false, false); >+ operationNameLabel.setLayoutData(gd); >+ >+ _operationNameText = toolkit.createText(sectionClient, "", SWT.SINGLE >+ | SWT.BORDER); >+ gd = new GridData(SWT.FILL, SWT.NONE, true, false); >+ gd.minimumWidth = SWT.DEFAULT; >+ gd.horizontalSpan = 2; >+ _operationNameText.setLayoutData(gd); >+ >+ Label operationReturnTypeLabel = toolkit.createLabel(sectionClient, >+ Messages.OP_RETURN_TYPE); >+ gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, SWT.NONE, false, >+ false); >+ operationReturnTypeLabel.setLayoutData(gd); >+ >+ _operationReturnType = new Text(sectionClient, SWT.SINGLE | SWT.BORDER); >+ gd = new GridData(SWT.FILL, SWT.NONE, true, false); >+ _operationReturnType.setLayoutData(gd); >+ _operationReturnType.setEditable(false); >+ >+ _changeReturnTypeButton = createPushButton( >+ sectionClient, >+ toolkit, >+ org.eclipse.tptp.wsdm.tooling.nls.messages.capability.internal.Messages.CHANGE_BUTTON_LABEL, >+ new Listener() { >+ public void handleEvent(Event event) >+ { >+ changeOperationReturnType(); >+ } >+ }); >+ gd = new GridData(GridData.END, SWT.NONE, false, false); >+ _changeReturnTypeButton.setLayoutData(gd); >+ >+ _importTypeButton = createPushButton( >+ sectionClient, >+ toolkit, >+ org.eclipse.tptp.wsdm.tooling.nls.messages.capability.internal.Messages.IMPORT_COMPLEX_DATA_TYPE, >+ new Listener() { >+ public void handleEvent(Event event) >+ { >+ importComplexTypes(); >+ } >+ }); >+ gd = new GridData(GridData.END, SWT.NONE, false, false); >+ gd.horizontalSpan = 3; >+ _importTypeButton.setLayoutData(gd); >+ _importTypeButton.setEnabled(!_editor.isReadOnly()); >+ >+ enable(!_editor.isReadOnly()); >+ } >+ >+ private void importComplexTypes() >+ { >+ ImportComplexTypeAction action = new ImportComplexTypeAction(getForm() >+ .getShell()); >+ action.run(); >+ } >+ >+ /** >+ * Refreshes the section. >+ */ >+ public void refresh() >+ { >+ } >+ >+ /** >+ * Initializes control listeners. >+ */ >+ public void hookAllListeners() >+ { >+ _operationNameText.addModifyListener(new ModifyListener() { >+ public void modifyText(ModifyEvent e) > { >- public void handleEvent(Event event) >- { >- changeOperationReturnType(); >- } >- }); >- gd = new GridData(GridData.END, SWT.NONE, false, false); >- _changeReturnTypeButton.setLayoutData(gd); >- >- _importTypeButton = createPushButton(sectionClient, toolkit, >- org.eclipse.tptp.wsdm.tooling.nls.messages.capability.internal.Messages.IMPORT_COMPLEX_DATA_TYPE, >- new Listener() >- { >- public void handleEvent(Event event) >- { >- importComplexTypes(); >- } >+ changeOperationName(); >+ } > }); >- gd = new GridData(GridData.END, SWT.NONE, false, false); >- gd.horizontalSpan = 3; >- _importTypeButton.setLayoutData(gd); >- _importTypeButton.setEnabled(!_editor.isReadOnly()); >- >- enable(!_editor.isReadOnly()); >- } >- >- private void importComplexTypes() >- { >- ImportComplexTypeAction action = new ImportComplexTypeAction(getForm().getShell()); >- action.run(); >- } >- >- /** >- * Refreshes the section. >- */ >- public void refresh() >- { >- } >- >- /** >- * Initializes control listeners. >- */ >- public void hookAllListeners() >- { >- _operationNameText.addModifyListener(new ModifyListener() >- { >- public void modifyText(ModifyEvent e) >- { >- changeOperationName(); >- } >- }); >- } >- >- private void changeOperationName() >- { >- if (_selectedOperation != null) >- { >- String newName = _operationNameText.getText(); >- String oldName = _selectedOperation.getName(); >- if (!newName.equals(oldName)) >- { >- ChangeOperationNameCommand command = new ChangeOperationNameCommand( >- _selectedOperation, newName); >- command.execute(); >- _page.setDirty(); >- } >- } >- } >- >- private void changeOperationReturnType() >- { >- if (_selectedOperation != null) >+ } >+ >+ private void changeOperationName() >+ { >+ if (_selectedOperation != null) >+ { >+ String newName = _operationNameText.getText(); >+ String oldName = _selectedOperation.getName(); >+ if (!newName.equals(oldName)) >+ { >+ ChangeOperationNameCommand command = new ChangeOperationNameCommand( >+ _selectedOperation, newName); >+ command.execute(); >+ _page.setDirty(); >+ } >+ } >+ } >+ >+ private void changeOperationReturnType() >+ { >+ if (_selectedOperation != null) >+ { >+ ChangeDataTypeDialog dialog = new ChangeDataTypeDialog(getForm() >+ .getShell(), Messages.CHANGE_RETURN_TYPE, true); >+ if (dialog.open() == Window.OK) >+ { >+ DataType dataType = dialog.getNewDataType(); >+ ChangeOperationReturnTypeCommand command = new ChangeOperationReturnTypeCommand( >+ _selectedOperation, dataType); >+ command.execute(); >+ _page.setDirty(); >+ } >+ } >+ } >+ >+ private String getSelectedOpReturnType() >+ { >+ XSDElementDeclaration returnTypeDeclaration = WsdlUtils >+ .getReturnTypeElement(_selectedOperation); >+ return XsdUtils.getType(returnTypeDeclaration); >+ } >+ >+ /** >+ * Handle viewer selection changed. >+ */ >+ public void selectionChanged(SelectionChangedEvent event) > { >- ChangeDataTypeDialog dialog = new ChangeDataTypeDialog(getForm().getShell(),Messages.CHANGE_RETURN_TYPE, true); >- if(dialog.open() == Window.OK) >+ showOpNameDetails(); >+ showOpReturnTypeDetails(); >+ // TODO Remove this once able to handle WSDL Import properly >+ enableDisableReturnType(); >+ } >+ >+ private void showOpNameDetails() >+ { >+ _operationNameText.setEnabled(!_editor.isReadOnly()); >+ String operationName = WsdlUtils.getOperationName(_selectedOperation); >+ if (!_operationNameText.getText().equals(operationName)) >+ _operationNameText.setText(operationName); >+ } >+ >+ private void showOpReturnTypeDetails() >+ { >+ Part returnTypePart = WsdlUtils >+ .getReturnTypeMessagePart(_selectedOperation); >+ XSDElementDeclaration returnTypeDeclaration = returnTypePart >+ .getElementDeclaration(); >+ if (returnTypeDeclaration == null) > { >- DataType dataType = dialog.getNewDataType(); >- ChangeOperationReturnTypeCommand command = new ChangeOperationReturnTypeCommand(_selectedOperation, dataType); >- command.execute(); >- _page.setDirty(); >+ _operationReturnType.setText("void"); >+ return; > } >+ String type = XsdUtils.getType(returnTypeDeclaration); >+ _operationReturnType.setText(type); > } >- } > >- private String getSelectedOpReturnType() >- { >- XSDElementDeclaration returnTypeDeclaration = WsdlUtils >- .getReturnTypeElement(_selectedOperation); >- return XsdUtils.getType(returnTypeDeclaration); >- } >- >- /** >- * Handle viewer selection changed. >- */ >- public void selectionChanged(SelectionChangedEvent event) >- { >- showOpNameDetails(); >- showOpReturnTypeDetails(); >- // TODO Remove this once able to handle WSDL Import properly >- enableDisableReturnType(); >- } >- >- private void showOpNameDetails() >- { >- _operationNameText.setEnabled(!_editor.isReadOnly()); >- String operationName = WsdlUtils.getOperationName(_selectedOperation); >- if (!_operationNameText.getText().equals(operationName)) >- _operationNameText.setText(operationName); >- } >- >- private void showOpReturnTypeDetails() >- { >- Part returnTypePart = WsdlUtils.getReturnTypeMessagePart(_selectedOperation); >- XSDElementDeclaration returnTypeDeclaration = returnTypePart.getElementDeclaration(); >- if(returnTypeDeclaration == null){ >- _operationReturnType.setText("void"); >- return; >- } >- String type = XsdUtils.getType(returnTypeDeclaration); >- _operationReturnType.setText(type); >- } >- >- private void enableDisableReturnType() >- { >- Definition capDefinition = _editor.getCapabilityDomain().getDefinition(); >- Message operationMessage = _selectedOperation.getEInput().getEMessage(); >- boolean isImportedOperation = true; >- if(operationMessage != null) >- isImportedOperation = !operationMessage.getEnclosingDefinition().equals(capDefinition); >- >- _operationReturnType.setEnabled(!isImportedOperation && !_editor.isReadOnly()); >- _changeReturnTypeButton.setEnabled(!isImportedOperation && !_editor.isReadOnly()); >- } >- >- /** >- * Update its selected object. >- */ >- public void setSelectedObject(Object object) >- { >- if (object instanceof Operation) >- _selectedOperation = (Operation) object; >- } >- >- /** >- * Enable or disable the section based on parameter passed. >- */ >- public void enable(boolean enabled) >- { >- _operationNameText.setEnabled(enabled); >- _operationReturnType.setEnabled(enabled); >- _changeReturnTypeButton.setEnabled(enabled); >- } >+ private void enableDisableReturnType() >+ { >+ Definition capDefinition = _editor.getCapabilityDomain() >+ .getCapability().getDefinition(); >+ Message operationMessage = _selectedOperation.getEInput().getEMessage(); >+ boolean isImportedOperation = true; >+ if (operationMessage != null) >+ isImportedOperation = !operationMessage.getEnclosingDefinition() >+ .equals(capDefinition); >+ >+ _operationReturnType.setEnabled(!isImportedOperation >+ && !_editor.isReadOnly()); >+ _changeReturnTypeButton.setEnabled(!isImportedOperation >+ && !_editor.isReadOnly()); >+ } >+ >+ /** >+ * Update its selected object. >+ */ >+ public void setSelectedObject(Object object) >+ { >+ if (object instanceof Operation) >+ _selectedOperation = (Operation) object; >+ } >+ >+ /** >+ * Enable or disable the section based on parameter passed. >+ */ >+ public void enable(boolean enabled) >+ { >+ _operationNameText.setEnabled(enabled); >+ _operationReturnType.setEnabled(enabled); >+ _changeReturnTypeButton.setEnabled(enabled); >+ } > > } >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/overview/internal/DetailsSection.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.editor.capability/src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/overview/internal/DetailsSection.java,v >retrieving revision 1.7 >diff -u -r1.7 DetailsSection.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/overview/internal/DetailsSection.java 9 Jan 2007 19:51:45 -0000 1.7 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/overview/internal/DetailsSection.java 20 Jan 2007 13:33:38 -0000 >@@ -51,266 +51,267 @@ > public class DetailsSection extends AbstractPageSection > { > >- private Text _capabilityNameText; >+ private Text _capabilityNameText; > >- private Text _namespaceText; >+ private Text _namespaceText; > >- private Text _descriptionText; >+ private Text _descriptionText; > >- private Label _errorLabel; >+ private Label _errorLabel; > >- private String _capabilityName; >- >- private String _namespace; >- >- private String _description; >- >- private boolean _dialogThrown = false; >- >- /** >- * Creates a new object of this class. >- */ >- DetailsSection(CapabilityEditor editor, IUIPage overviewPage, >- ScrolledForm form, FormToolkit toolkit) >- { >- super(editor, overviewPage, form, toolkit); >- } >- >- /** >- * Creates the section. >- */ >- public void create() >- { >- Composite sectionClient = createSection(Messages.GENERAL_INFO, >- Messages.GENERAL_INFO_OF_CAP); >- GridLayout layout = new GridLayout(2, false); >- layout.marginWidth = LAYOUT_MARGIN_WIDTH; >- layout.verticalSpacing = LAYOUT_VERTICAL_SPACING; >- layout.horizontalSpacing = LAYOUT_HORIZONTAL_SPACING; >- sectionClient.setLayout(layout); >- FormToolkit toolkit = getToolkit(); >- >- Label capabilityNameLabel = toolkit.createLabel(sectionClient, >- Messages.CAP_NAME); >- GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, SWT.NONE, false, false); >- capabilityNameLabel.setLayoutData(gd); >- >- _capabilityNameText = toolkit.createText(sectionClient, "", SWT.SINGLE >- | SWT.BORDER); >- gd = new GridData(SWT.FILL, SWT.NONE, true, false); >- gd.minimumWidth = SWT.DEFAULT; >- _capabilityNameText.setLayoutData(gd); >- _capabilityNameText.setEditable(!_editor.isReadOnly()); >- >- Label namespaceLabel = toolkit.createLabel(sectionClient, >- Messages.CAP_NAMESPACE); >- gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, SWT.NONE, false, false); >- namespaceLabel.setLayoutData(gd); >- >- _namespaceText = toolkit.createText(sectionClient, "", SWT.SINGLE >- | SWT.BORDER); >- gd = new GridData(SWT.FILL, SWT.NONE, true, false); >- gd.minimumWidth = SWT.DEFAULT; >- _namespaceText.setLayoutData(gd); >- _namespaceText.setEditable(!_editor.isReadOnly()); >- >- Label descriptionLabel = toolkit.createLabel(sectionClient, >- Messages.CAP_DESCRIPTION); >- gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, SWT.NONE, false, false); >- descriptionLabel.setLayoutData(gd); >- >- _descriptionText = toolkit.createText(sectionClient, "", SWT.SINGLE >- | SWT.BORDER); >- gd = new GridData(SWT.FILL, SWT.NONE, true, false); >- gd.minimumWidth = SWT.DEFAULT; >- _descriptionText.setLayoutData(gd); >- _descriptionText.setEditable(!_editor.isReadOnly()); >- >- _errorLabel = toolkit.createLabel(sectionClient, "", SWT.WRAP); >- gd = new GridData(GridData.FILL_HORIZONTAL); >- gd.horizontalSpan = 2; >- _errorLabel.setLayoutData(gd); >- } >- >- /** >- * Refreshes the section. >- */ >- public void refresh() >- { >- Capability model = _editor.getCapabilityDomain().getCapability(); >- _capabilityName = model.getName(); >- _namespace = model.getNamespace(); >- _description = model.getDescription(); >- if (!_capabilityNameText.getText().equals(_capabilityName)) >- _capabilityNameText.setText(_capabilityName); >- if (!_namespaceText.getText().equals(_namespace)) >- _namespaceText.setText(_namespace); >- if (!_descriptionText.getText().equals(_description)) >- _descriptionText.setText(_description); >- updateErrorMessage(); >- } >- >- /** >- * Initializes control listeners. >- */ >- public void hookAllListeners() >- { >- _capabilityNameText.addModifyListener(new ModifyListener() >- { >- public void modifyText(ModifyEvent e) >- { >- changeCapabilityName(); >- } >- }); >- _capabilityNameText.addFocusListener(new FocusAdapter(){ >- public void focusGained(FocusEvent e) >- { >- _dialogThrown = false; >- } >- }); >- _namespaceText.addModifyListener(new ModifyListener() >- { >- public void modifyText(ModifyEvent e) >- { >- changeCapabilityNamespace(); >- } >- }); >- _namespaceText.addFocusListener(new FocusAdapter() >- { >- public void focusGained(FocusEvent e) >- { >- if (!_dialogThrown) >+ private String _capabilityName; >+ >+ private String _namespace; >+ >+ private String _description; >+ >+ private boolean _dialogThrown = false; >+ >+ /** >+ * Creates a new object of this class. >+ */ >+ DetailsSection(CapabilityEditor editor, IUIPage overviewPage, >+ ScrolledForm form, FormToolkit toolkit) >+ { >+ super(editor, overviewPage, form, toolkit); >+ } >+ >+ /** >+ * Creates the section. >+ */ >+ public void create() >+ { >+ Composite sectionClient = createSection(Messages.GENERAL_INFO, >+ Messages.GENERAL_INFO_OF_CAP); >+ GridLayout layout = new GridLayout(2, false); >+ layout.marginWidth = LAYOUT_MARGIN_WIDTH; >+ layout.verticalSpacing = LAYOUT_VERTICAL_SPACING; >+ layout.horizontalSpacing = LAYOUT_HORIZONTAL_SPACING; >+ sectionClient.setLayout(layout); >+ FormToolkit toolkit = getToolkit(); >+ >+ Label capabilityNameLabel = toolkit.createLabel(sectionClient, >+ Messages.CAP_NAME); >+ GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, >+ SWT.NONE, false, false); >+ capabilityNameLabel.setLayoutData(gd); >+ >+ _capabilityNameText = toolkit.createText(sectionClient, "", SWT.SINGLE >+ | SWT.BORDER); >+ gd = new GridData(SWT.FILL, SWT.NONE, true, false); >+ gd.minimumWidth = SWT.DEFAULT; >+ _capabilityNameText.setLayoutData(gd); >+ _capabilityNameText.setEditable(!_editor.isReadOnly()); >+ >+ Label namespaceLabel = toolkit.createLabel(sectionClient, >+ Messages.CAP_NAMESPACE); >+ gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, SWT.NONE, false, >+ false); >+ namespaceLabel.setLayoutData(gd); >+ >+ _namespaceText = toolkit.createText(sectionClient, "", SWT.SINGLE >+ | SWT.BORDER); >+ gd = new GridData(SWT.FILL, SWT.NONE, true, false); >+ gd.minimumWidth = SWT.DEFAULT; >+ _namespaceText.setLayoutData(gd); >+ _namespaceText.setEditable(!_editor.isReadOnly()); >+ >+ Label descriptionLabel = toolkit.createLabel(sectionClient, >+ Messages.CAP_DESCRIPTION); >+ gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, SWT.NONE, false, >+ false); >+ descriptionLabel.setLayoutData(gd); >+ >+ _descriptionText = toolkit.createText(sectionClient, "", SWT.SINGLE >+ | SWT.BORDER); >+ gd = new GridData(SWT.FILL, SWT.NONE, true, false); >+ gd.minimumWidth = SWT.DEFAULT; >+ _descriptionText.setLayoutData(gd); >+ _descriptionText.setEditable(!_editor.isReadOnly()); >+ >+ _errorLabel = toolkit.createLabel(sectionClient, "", SWT.WRAP); >+ gd = new GridData(GridData.FILL_HORIZONTAL); >+ gd.horizontalSpan = 2; >+ _errorLabel.setLayoutData(gd); >+ } >+ >+ /** >+ * Refreshes the section. >+ */ >+ public void refresh() >+ { >+ Capability model = _editor.getCapabilityDomain().getCapability(); >+ _capabilityName = model.getName(); >+ _namespace = model.getNamespace(); >+ _description = model.getDescription(); >+ if (!_capabilityNameText.getText().equals(_capabilityName)) >+ _capabilityNameText.setText(_capabilityName); >+ if (!_namespaceText.getText().equals(_namespace)) >+ _namespaceText.setText(_namespace); >+ if (!_descriptionText.getText().equals(_description)) >+ _descriptionText.setText(_description); >+ updateErrorMessage(); >+ } >+ >+ /** >+ * Initializes control listeners. >+ */ >+ public void hookAllListeners() >+ { >+ _capabilityNameText.addModifyListener(new ModifyListener() { >+ public void modifyText(ModifyEvent e) >+ { >+ changeCapabilityName(); >+ } >+ }); >+ _capabilityNameText.addFocusListener(new FocusAdapter() { >+ public void focusGained(FocusEvent e) >+ { >+ _dialogThrown = false; >+ } >+ }); >+ _namespaceText.addModifyListener(new ModifyListener() { >+ public void modifyText(ModifyEvent e) >+ { >+ changeCapabilityNamespace(); >+ } >+ }); >+ _namespaceText.addFocusListener(new FocusAdapter() { >+ public void focusGained(FocusEvent e) >+ { >+ if (!_dialogThrown) >+ { >+ Definition definition = _editor.getCapabilityDomain() >+ .getCapability().getDefinition(); >+ List importsWsdl = definition.getImports(definition >+ .getTargetNamespace()); >+ if (importsWsdl.size() > 0) >+ { >+ _dialogThrown = true; >+ boolean ok = MessageDialog >+ .openConfirm( >+ getForm().getShell(), >+ org.eclipse.tptp.wsdm.tooling.nls.messages.capability.internal.Messages.CONFIRM_MESSAGE, >+ Messages.IMPORT_WSDL_NS_CHANGE_MESSAGE); >+ if (!ok) >+ _capabilityNameText.setFocus(); >+ } >+ >+ } >+ } >+ }); >+ _descriptionText.addModifyListener(new ModifyListener() { >+ public void modifyText(ModifyEvent e) >+ { >+ changeCapabilityDescription(); >+ } >+ }); >+ _descriptionText.addFocusListener(new FocusAdapter() { >+ public void focusGained(FocusEvent e) >+ { >+ _dialogThrown = false; >+ } >+ }); >+ } >+ >+ private void changeCapabilityName() >+ { >+ if (!_capabilityNameText.getText().equals(_capabilityName)) >+ { >+ CapabilityDomain capabilityDomain = _editor.getCapabilityDomain(); >+ String newName = _capabilityNameText.getText(); >+ ChangeCapabilityNameCommand command = new ChangeCapabilityNameCommand( >+ capabilityDomain, newName); >+ command.execute(); >+ _page.setDirty(); >+ } >+ } >+ >+ private void changeCapabilityNamespace() >+ { >+ if (!_namespaceText.getText().equals(_namespace)) >+ { >+ CapabilityDomain capabilityDomain = _editor.getCapabilityDomain(); >+ String newNS = _namespaceText.getText(); >+ ChangeCapabilityNamespaceCommand command = new ChangeCapabilityNamespaceCommand( >+ capabilityDomain, newNS); >+ command.execute(); >+ _page.setDirty(); >+ } >+ } >+ >+ private void changeCapabilityDescription() >+ { >+ if (!_descriptionText.getText().equals(_description)) >+ { >+ CapabilityDomain capabilityDomain = _editor.getCapabilityDomain(); >+ String newDescription = _descriptionText.getText(); >+ ChangeCapabilityDescriptionCommand command = new ChangeCapabilityDescriptionCommand( >+ capabilityDomain, newDescription); >+ command.execute(); >+ _page.setDirty(); >+ } >+ } >+ >+ /** >+ * Handle viewer selection changed. >+ */ >+ public void selectionChanged(SelectionChangedEvent event) >+ { >+ } >+ >+ /** >+ * Update its selected object. >+ */ >+ public void setSelectedObject(Object object) >+ { >+ } >+ >+ /** >+ * Enable or disable the section based on parameter passed. >+ */ >+ public void enable(boolean enabled) >+ { >+ } >+ >+ private void updateErrorMessage() >+ { >+ Definition defintion = _editor.getCapabilityDomain().getCapability() >+ .getDefinition(); >+ CapabilityWSDLValidator validator = new CapabilityWSDLValidator(); >+ IValidationReport report = validator.validate(defintion); >+ boolean hasProblem = report.hasErrors() || report.hasWarnings(); >+ if (hasProblem) > { >- Definition definition = _editor.getCapabilityDomain().getDefinition(); >- List importsWsdl = definition.getImports(definition >- .getTargetNamespace()); >- if (importsWsdl.size() > 0) >- { >- _dialogThrown = true; >- boolean ok = MessageDialog >- .openConfirm( >- getForm().getShell(), >- org.eclipse.tptp.wsdm.tooling.nls.messages.capability.internal.Messages.CONFIRM_MESSAGE, >- Messages.IMPORT_WSDL_NS_CHANGE_MESSAGE); >- if(!ok) >- _capabilityNameText.setFocus(); >- } >- >+ // We have a problem, is it an error or just a warning? >+ boolean hasError = false; >+ String msg; >+ if (report.hasErrors()) >+ { >+ hasError = true; >+ msg = report.getErrorMessages()[0].getMessage(); >+ } >+ else >+ { >+ msg = report.getWarningMessages()[0].getMessage(); >+ } >+ _errorLabel.setBackground(getForm().getDisplay().getSystemColor( >+ hasError ? SWT.COLOR_RED : SWT.COLOR_YELLOW)); >+ _errorLabel.setForeground(getForm().getDisplay().getSystemColor( >+ hasError ? SWT.COLOR_WHITE : SWT.COLOR_BLACK)); >+ _errorLabel.setText(" " + msg + " "); > } >- } >- }); >- _descriptionText.addModifyListener(new ModifyListener() >- { >- public void modifyText(ModifyEvent e) >- { >- changeCapabilityDescription(); >- } >- }); >- _descriptionText.addFocusListener(new FocusAdapter(){ >- public void focusGained(FocusEvent e) >- { >+ else >+ { >+ _errorLabel.setBackground(getForm().getBackground()); >+ _errorLabel.setForeground(getForm().getForeground()); >+ _errorLabel.setText(""); >+ } >+ } >+ >+ public void pageChange(int newPageIndex) >+ { > _dialogThrown = false; >- } >- }); >- } >- >- private void changeCapabilityName() >- { >- if (!_capabilityNameText.getText().equals(_capabilityName)) >- { >- CapabilityDomain capabilityDomain = _editor.getCapabilityDomain(); >- String newName = _capabilityNameText.getText(); >- ChangeCapabilityNameCommand command = new ChangeCapabilityNameCommand( >- capabilityDomain, newName); >- command.execute(); >- _page.setDirty(); >- } >- } >- >- private void changeCapabilityNamespace() >- { >- if (!_namespaceText.getText().equals(_namespace)) >- { >- CapabilityDomain capabilityDomain = _editor.getCapabilityDomain(); >- String newNS = _namespaceText.getText(); >- ChangeCapabilityNamespaceCommand command = new ChangeCapabilityNamespaceCommand( >- capabilityDomain, newNS); >- command.execute(); >- _page.setDirty(); >- } >- } >- >- private void changeCapabilityDescription() >- { >- if (!_descriptionText.getText().equals(_description)) >- { >- CapabilityDomain capabilityDomain = _editor.getCapabilityDomain(); >- String newDescription = _descriptionText.getText(); >- ChangeCapabilityDescriptionCommand command = new ChangeCapabilityDescriptionCommand( >- capabilityDomain, newDescription); >- command.execute(); >- _page.setDirty(); >- } >- } >- >- /** >- * Handle viewer selection changed. >- */ >- public void selectionChanged(SelectionChangedEvent event) >- { >- } >- >- /** >- * Update its selected object. >- */ >- public void setSelectedObject(Object object) >- { >- } >- >- /** >- * Enable or disable the section based on parameter passed. >- */ >- public void enable(boolean enabled) >- { >- } >- >- private void updateErrorMessage() >- { >- Definition defintion = _editor.getCapabilityDomain().getDefinition(); >- CapabilityWSDLValidator validator = new CapabilityWSDLValidator(); >- IValidationReport report = validator.validate(defintion); >- boolean hasProblem = report.hasErrors() || report.hasWarnings(); >- if (hasProblem) >- { >- // We have a problem, is it an error or just a warning? >- boolean hasError = false; >- String msg; >- if (report.hasErrors()) >- { >- hasError = true; >- msg = report.getErrorMessages()[0].getMessage(); >- } >- else >- { >- msg = report.getWarningMessages()[0].getMessage(); >- } >- _errorLabel.setBackground(getForm().getDisplay().getSystemColor( >- hasError ? SWT.COLOR_RED : SWT.COLOR_YELLOW)); >- _errorLabel.setForeground(getForm().getDisplay().getSystemColor( >- hasError ? SWT.COLOR_WHITE : SWT.COLOR_BLACK)); >- _errorLabel.setText(" " + msg + " "); >- } >- else >- { >- _errorLabel.setBackground(getForm().getBackground()); >- _errorLabel.setForeground(getForm().getForeground()); >- _errorLabel.setText(""); >- } >- } >- >- public void pageChange(int newPageIndex) >- { >- _dialogThrown = false; >- } >+ } > > } >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/topic/internal/AddRootTopicCommand.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.editor.capability/src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/topic/internal/AddRootTopicCommand.java,v >retrieving revision 1.3 >diff -u -r1.3 AddRootTopicCommand.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/topic/internal/AddRootTopicCommand.java 9 Jan 2007 19:51:44 -0000 1.3 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/topic/internal/AddRootTopicCommand.java 20 Jan 2007 13:33:32 -0000 >@@ -10,106 +10,102 @@ > * IBM Corporation - initial API and implementation > *******************************************************************************/ > >- > package org.eclipse.tptp.wsdm.tooling.editor.capability.command.topic.internal; > > import java.util.List; > > import org.eclipse.tptp.wsdm.tooling.editor.capability.internal.CapabilityDomain; > import org.eclipse.tptp.wsdm.tooling.editor.capability.util.internal.MetaDataUtils; >+import org.eclipse.tptp.wsdm.tooling.model.capabilities.CapabilitiesFactory; > import org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability; > import org.eclipse.tptp.wsdm.tooling.model.capabilities.Topic; > import org.eclipse.tptp.wsdm.tooling.model.capabilities.TopicSpace; >+import org.eclipse.tptp.wsdm.tooling.model.capabilities.impl.MetadataDescriptor; > import org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.PropertyType; >-import org.eclipse.tptp.wsdm.tooling.util.internal.PropertyMetaDataDescriptor; >-import org.eclipse.tptp.wsdm.tooling.util.internal.TopicUtils; > import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmConstants; > >- > /** > * > * Command class to add new root topic to topicspace.<br> >- * If the given topicnamespace doesn't exists in model then it will create new TopicSpace.<br> >- * If RMD doesn't contain any <b>TopicExpression</b> property then it will create new TopicExpression property in RMD. >+ * If the given topicnamespace doesn't exists in model then it will create new >+ * TopicSpace.<br> >+ * If RMD doesn't contain any <b>TopicExpression</b> property then it will >+ * create new TopicExpression property in RMD. >+ * > * >- * > */ > > public class AddRootTopicCommand > { > >- private Capability _capability; >+ private Capability _capability; > >- private String _topicNamespace; >+ private String _topicNamespace; > >- private Topic _rootTopic; >+ private Topic _rootTopic; > >- private CapabilityDomain _capabilityDomain; >+ private CapabilityDomain _capabilityDomain; > >- /** >- * Creates a new object of this class. >- */ >- public AddRootTopicCommand(CapabilityDomain capabilityDomain, >- String topicNamespace, Topic rootTopic) >- { >- _capabilityDomain = capabilityDomain; >- _capability = capabilityDomain.getCapability(); >- _topicNamespace = topicNamespace; >- _rootTopic = rootTopic; >- } >- >- /** >- * Execute the command. >- */ >- public void execute() >- { >- PropertyMetaDataDescriptor propertyMetaDataDescriptor = _capabilityDomain >- .getMetaDataDescriptor(); >- if (propertyMetaDataDescriptor == null) >+ /** >+ * Creates a new object of this class. >+ */ >+ public AddRootTopicCommand(CapabilityDomain capabilityDomain, >+ String topicNamespace, Topic rootTopic) > { >- propertyMetaDataDescriptor = createMetaDataDescriptor(); >+ _capabilityDomain = capabilityDomain; >+ _capability = capabilityDomain.getCapability(); >+ _topicNamespace = topicNamespace; >+ _rootTopic = rootTopic; > } > >- PropertyType topicExpressionProperty = propertyMetaDataDescriptor >- .getTopicExpressionProperty(); >- if (topicExpressionProperty == null) >+ /** >+ * Execute the command. >+ */ >+ public void execute() > { >- propertyMetaDataDescriptor.createTopicExpressionProperty(); >+ MetadataDescriptor propertyMetaDataDescriptor = _capabilityDomain >+ .getCapability().getMetadata(); >+ if (propertyMetaDataDescriptor == null) >+ propertyMetaDataDescriptor = createMetaDataDescriptor(); >+ >+ PropertyType topicExpressionProperty = propertyMetaDataDescriptor >+ .getTopicExpressionProperty(); >+ if (topicExpressionProperty == null) >+ propertyMetaDataDescriptor.createTopicExpressionProperty(); >+ >+ TopicSpace topicSpace = getTopicSpace(); >+ if (topicSpace == null) >+ { >+ topicSpace = CapabilitiesFactory.eINSTANCE.createTopicSpace(); >+ topicSpace.setName(_topicNamespace); >+ topicSpace.setNamespace(_topicNamespace); >+ _capability.getTopicSpaces().add(topicSpace); >+ } >+ >+ _rootTopic.setParent(null); >+ topicSpace.getRootTopics().add(_rootTopic); > } > >- TopicSpace topicSpace = getTopicSpace(); >- if (topicSpace == null) >+ private TopicSpace getTopicSpace() > { >- topicSpace = TopicUtils.createNewTopicSpace(); >- topicSpace.setName(_topicNamespace); >- topicSpace.setNamespace(_topicNamespace); >- _capability.getTopicSpaces().add(topicSpace); >+ if (_capability.getTopicSpaces() == null) >+ return null; >+ List topicSpaces = _capability.getTopicSpaces(); >+ for (int i = 0; i < topicSpaces.size(); i++) >+ { >+ TopicSpace topicSpace = (TopicSpace) topicSpaces.get(i); >+ if (topicSpace.getNamespace().equals(_topicNamespace)) >+ return topicSpace; >+ } >+ return null; > } > >- _rootTopic.setParent(null); >- topicSpace.getRootTopics().add(_rootTopic); >- } >- >- private TopicSpace getTopicSpace() >- { >- if (_capability.getTopicSpaces() == null) >- return null; >- List topicSpaces = _capability.getTopicSpaces(); >- for (int i = 0; i < topicSpaces.size(); i++) >+ private MetadataDescriptor createMetaDataDescriptor() > { >- TopicSpace topicSpace = (TopicSpace) topicSpaces.get(i); >- if (topicSpace.getNamespace().equals(_topicNamespace)) >- return topicSpace; >+ MetadataDescriptor propertyMetaDataDescriptor = MetaDataUtils >+ .createMetaDataDescriptor(_capabilityDomain); >+ propertyMetaDataDescriptor.getDocumentRoot().getXMLNSPrefixMap().put( >+ "wsnt", WsdmConstants.WSNT_NS); >+ return propertyMetaDataDescriptor; > } >- return null; >- } >- >- private PropertyMetaDataDescriptor createMetaDataDescriptor() >- { >- PropertyMetaDataDescriptor propertyMetaDataDescriptor = MetaDataUtils >- .createMetaDataDescriptor(_capabilityDomain); >- propertyMetaDataDescriptor.getDocumentRoot().getXMLNSPrefixMap().put( >- "wsnt", WsdmConstants.WSNT_NS); >- return propertyMetaDataDescriptor; >- } > } >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/topic/internal/RemoveTopicNamespaceCommand.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.editor.capability/src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/topic/internal/RemoveTopicNamespaceCommand.java,v >retrieving revision 1.3 >diff -u -r1.3 RemoveTopicNamespaceCommand.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/topic/internal/RemoveTopicNamespaceCommand.java 9 Jan 2007 19:51:44 -0000 1.3 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/topic/internal/RemoveTopicNamespaceCommand.java 20 Jan 2007 13:33:32 -0000 >@@ -16,7 +16,7 @@ > import org.eclipse.tptp.wsdm.tooling.editor.capability.internal.CapabilityDomain; > import org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability; > import org.eclipse.tptp.wsdm.tooling.model.capabilities.TopicSpace; >-import org.eclipse.tptp.wsdm.tooling.util.internal.PropertyMetaDataDescriptor; >+import org.eclipse.tptp.wsdm.tooling.model.capabilities.impl.MetadataDescriptor; > > /** > * >@@ -39,9 +39,9 @@ > public RemoveTopicNamespaceCommand(CapabilityDomain capabilityDomain, > TopicSpace topicSpace) > { >- _capabilityDomain = capabilityDomain; >- _capability = capabilityDomain.getCapability(); >- _topicSpace = topicSpace; >+ _capabilityDomain = capabilityDomain; >+ _capability = capabilityDomain.getCapability(); >+ _topicSpace = topicSpace; > } > > /** >@@ -50,17 +50,16 @@ > */ > public void execute() > { >- removeNSFromMetadata(); >- _capability.getTopicSpaces().remove(_topicSpace); >+ removeNSFromMetadata(); >+ _capability.getTopicSpaces().remove(_topicSpace); > } > > private void removeNSFromMetadata() > { >- PropertyMetaDataDescriptor propertyMetaDataDescriptor = _capabilityDomain >- .getMetaDataDescriptor(); >- String prefix = propertyMetaDataDescriptor.getPrefix(_topicSpace >- .getNamespace()); >- propertyMetaDataDescriptor.getDocumentRoot().getXMLNSPrefixMap() >- .remove(prefix); >+ MetadataDescriptor metaDataDescriptor = _capabilityDomain.getCapability().getMetadata(); >+ String prefix = metaDataDescriptor.getPrefix(_topicSpace >+ .getNamespace()); >+ metaDataDescriptor.getDocumentRoot().getXMLNSPrefixMap() >+ .remove(prefix); > } > } >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/property/internal/MetricsSection.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.editor.capability/src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/property/internal/MetricsSection.java,v >retrieving revision 1.6 >diff -u -r1.6 MetricsSection.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/property/internal/MetricsSection.java 9 Jan 2007 19:51:43 -0000 1.6 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/property/internal/MetricsSection.java 20 Jan 2007 13:33:40 -0000 >@@ -38,7 +38,6 @@ > import org.eclipse.tptp.wsdm.tooling.editor.capability.internal.CapabilityDomain; > import org.eclipse.tptp.wsdm.tooling.editor.capability.internal.CapabilityEditor; > import org.eclipse.tptp.wsdm.tooling.editor.capability.internal.FormMetric; >-import org.eclipse.tptp.wsdm.tooling.editor.capability.util.internal.MetaDataUtils; > import org.eclipse.tptp.wsdm.tooling.editor.ui.internal.AbstractPageSection; > import org.eclipse.tptp.wsdm.tooling.editor.ui.internal.IUIPage; > import org.eclipse.tptp.wsdm.tooling.model.capabilities.Property; >@@ -56,267 +55,283 @@ > public class MetricsSection extends AbstractPageSection > { > >- private TableViewer _metricsViewer; >+ private TableViewer _metricsViewer; > >- private Property _selectedProperty; >+ private Property _selectedProperty; > >- /** >- * Creates the new object of this class. >- */ >- MetricsSection(CapabilityEditor editor, IUIPage page, ScrolledForm form, >- FormToolkit toolkit) >- { >- super(editor, page, form, toolkit); >- } >- >- /** >- * Creates the section. >- */ >- public void create() >- { >- Composite sectionClient = createSection(Messages.METRICS, >- Messages.METRICS_OF_PROP); >- GridLayout layout = new GridLayout(); >- layout.marginWidth = LAYOUT_MARGIN_WIDTH; >- layout.verticalSpacing = LAYOUT_VERTICAL_SPACING; >- layout.horizontalSpacing = LAYOUT_HORIZONTAL_SPACING; >- sectionClient.setLayout(layout); >- >- Table swtTable = getToolkit().createTable( >- sectionClient, >- SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL >- | SWT.MULTI); >- _metricsViewer = new TableViewer(swtTable); >- GridData gd = new GridData(SWT.FILL, SWT.NONE, true, false); >- _metricsViewer.getControl().setLayoutData(gd); >- >- Table table = _metricsViewer.getTable(); >- >- TableColumn column = new TableColumn(table, SWT.NONE, 0); >- column.setText(Messages.CHANGE_TYPE); >- column.setWidth(50); >- >- column = new TableColumn(table, SWT.NONE, 1); >- column.setText(Messages.TIME_SCOPE); >- column.setWidth(50); >- >- column = new TableColumn(table, SWT.NONE, 2); >- column.setText(Messages.GATHERING_TIME); >- column.setWidth(50); >- >- column = new TableColumn(table, SWT.NONE, 3); >- column.setText(Messages.CALCULATION_INTERVAL); >- column.setWidth(50); >- >- column = new TableColumn(table, SWT.NONE, 4); >- column.setText(Messages.METRIC_GROUP); >- column.setWidth(50); >- >- table.redraw(); >- table.setHeaderVisible(true); >- table.setLinesVisible(true); >- >- MetricsContentProvider contentProvider = new MetricsContentProvider( >- getForm().getShell()); >- _metricsViewer.setContentProvider(contentProvider); >- _metricsViewer.setLabelProvider(contentProvider.getLabelProvider()); >- >- attachCellEditors(); >- >- enable(!_editor.isReadOnly()); >- } >- >- private void attachCellEditors() >- { >- // Assign 'names' to each column >- _metricsViewer.setColumnProperties(FormMetric.COLUMN_NAMES); >+ /** >+ * Creates the new object of this class. >+ */ >+ MetricsSection(CapabilityEditor editor, IUIPage page, ScrolledForm form, >+ FormToolkit toolkit) >+ { >+ super(editor, page, form, toolkit); >+ } >+ >+ /** >+ * Creates the section. >+ */ >+ public void create() >+ { >+ Composite sectionClient = createSection(Messages.METRICS, >+ Messages.METRICS_OF_PROP); >+ GridLayout layout = new GridLayout(); >+ layout.marginWidth = LAYOUT_MARGIN_WIDTH; >+ layout.verticalSpacing = LAYOUT_VERTICAL_SPACING; >+ layout.horizontalSpacing = LAYOUT_HORIZONTAL_SPACING; >+ sectionClient.setLayout(layout); >+ >+ Table swtTable = getToolkit().createTable( >+ sectionClient, >+ SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL >+ | SWT.MULTI); >+ _metricsViewer = new TableViewer(swtTable); >+ GridData gd = new GridData(SWT.FILL, SWT.NONE, true, false); >+ _metricsViewer.getControl().setLayoutData(gd); >+ >+ Table table = _metricsViewer.getTable(); >+ >+ TableColumn column = new TableColumn(table, SWT.NONE, 0); >+ column.setText(Messages.CHANGE_TYPE); >+ column.setWidth(50); >+ >+ column = new TableColumn(table, SWT.NONE, 1); >+ column.setText(Messages.TIME_SCOPE); >+ column.setWidth(50); >+ >+ column = new TableColumn(table, SWT.NONE, 2); >+ column.setText(Messages.GATHERING_TIME); >+ column.setWidth(50); >+ >+ column = new TableColumn(table, SWT.NONE, 3); >+ column.setText(Messages.CALCULATION_INTERVAL); >+ column.setWidth(50); >+ >+ column = new TableColumn(table, SWT.NONE, 4); >+ column.setText(Messages.METRIC_GROUP); >+ column.setWidth(50); >+ >+ table.redraw(); >+ table.setHeaderVisible(true); >+ table.setLinesVisible(true); >+ >+ MetricsContentProvider contentProvider = new MetricsContentProvider( >+ getForm().getShell()); >+ _metricsViewer.setContentProvider(contentProvider); >+ _metricsViewer.setLabelProvider(contentProvider.getLabelProvider()); > >- Table table = _metricsViewer.getTable(); >- _metricsViewer.setCellEditors(new CellEditor[] { >+ attachCellEditors(); >+ >+ enable(!_editor.isReadOnly()); >+ } >+ >+ private void attachCellEditors() >+ { >+ // Assign 'names' to each column >+ _metricsViewer.setColumnProperties(FormMetric.COLUMN_NAMES); >+ >+ Table table = _metricsViewer.getTable(); >+ _metricsViewer.setCellEditors(new CellEditor[] { > // Change type >- new ComboBoxCellEditor(table, FormMetric.CTYPE_STR_ENUM, >- SWT.READ_ONLY), >- // Time scope >- new ComboBoxCellEditor(table, FormMetric.TSCOPE_STR_ENUM, >- SWT.READ_ONLY), >- // Gathering time >- new ComboBoxCellEditor(table, FormMetric.GTIME_STR_ENUM, >- SWT.READ_ONLY), >- // Calculation interval >- new XsdDurationCellEditor(table), >- // Metric group >- new TextCellEditor(table, SWT.RIGHT | SWT.READ_ONLY), }); >+ new ComboBoxCellEditor(table, FormMetric.CTYPE_STR_ENUM, >+ SWT.READ_ONLY), >+ // Time scope >+ new ComboBoxCellEditor(table, FormMetric.TSCOPE_STR_ENUM, >+ SWT.READ_ONLY), >+ // Gathering time >+ new ComboBoxCellEditor(table, FormMetric.GTIME_STR_ENUM, >+ SWT.READ_ONLY), >+ // Calculation interval >+ new XsdDurationCellEditor(table), >+ // Metric group >+ new TextCellEditor(table, SWT.RIGHT | SWT.READ_ONLY), }); >+ >+ _metricsViewer.setCellModifier(new ICellModifier() { >+ public boolean canModify(Object element, String property) >+ { >+ if (element instanceof FormMetric) >+ { >+ FormMetric metric = (FormMetric) element; >+ return metric.canModify(property); >+ } >+ throw new IllegalStateException(NLS.bind( >+ Messages.UNEXPECTED_TYPE_ERROR_, element.getClass())); >+ } >+ >+ public Object getValue(Object element, String property) >+ { >+ if (element instanceof FormMetric) >+ { >+ FormMetric metric = (FormMetric) element; >+ return metric.getColumnObject(property); >+ } >+ throw new IllegalStateException(NLS.bind( >+ Messages.UNEXPECTED_TYPE_ERROR_, element.getClass())); >+ } >+ >+ public void modify(Object element, String property, Object value) >+ { >+ TableItem ti = null; >+ if (element instanceof TableItem) >+ ti = (TableItem) element; >+ else if (element instanceof Table) >+ { >+ Table table = (Table) element; >+ ti = table.getItem(0); >+ } >+ else >+ return; >+ >+ FormMetric metric = (FormMetric) ti.getData(); >+ metric.setColumnObject(property, value); >+ _page.setDirty(); >+ /* >+ * CapabilityDomain capabilityDomain = _editor >+ * .getCapabilityDomain(); metric = >+ * MetaDataUtils.getMetric(capabilityDomain, _selectedProperty); >+ * _metricsViewer.setInput(metric); >+ */ >+ } >+ }); >+ } > >- _metricsViewer.setCellModifier(new ICellModifier() >+ /** >+ * Refreshes the section. >+ */ >+ public void refresh() > { >- public boolean canModify(Object element, String property) >- { >- if (element instanceof FormMetric) >+ _metricsViewer.refresh(); >+ } >+ >+ /** >+ * Initializes control listeners. >+ */ >+ public void hookAllListeners() >+ { >+ } >+ >+ /** >+ * Handle viewer selection changed. >+ */ >+ public void selectionChanged(SelectionChangedEvent event) >+ { >+ _metricsViewer.getTable().setEnabled( >+ _selectedProperty != null && !_editor.isReadOnly()); >+ if (_selectedProperty != null) > { >- FormMetric metric = (FormMetric) element; >- return metric.canModify(property); >+ FormMetric metric = createMetricFromProperty(); >+ _metricsViewer.setInput(metric); > } >- throw new IllegalStateException(NLS.bind(Messages.UNEXPECTED_TYPE_ERROR_, element.getClass())); >- } >+ } > >- public Object getValue(Object element, String property) >- { >- if (element instanceof FormMetric) >+ private FormMetric createMetricFromProperty() >+ { >+ CapabilityDomain capabilityDomain = _editor.getCapabilityDomain(); >+ FormMetric formMetric = new FormMetric(capabilityDomain, >+ _selectedProperty); >+ return formMetric; >+ } >+ >+ /** >+ * Update its selected object. >+ */ >+ public void setSelectedObject(Object object) >+ { >+ _selectedProperty = null; >+ if (object instanceof Property) > { >- FormMetric metric = (FormMetric) element; >- return metric.getColumnObject(property); >+ _selectedProperty = (Property) object; > } >- throw new IllegalStateException(NLS.bind(Messages.UNEXPECTED_TYPE_ERROR_, element.getClass())); >- } >+ } > >- public void modify(Object element, String property, Object value) >- { >- TableItem ti = (TableItem) element; >- FormMetric metric = (FormMetric) ti.getData(); >- metric.setColumnObject(property, value); >- _page.setDirty(); >- CapabilityDomain capabilityDomain = _editor >- .getCapabilityDomain(); >- metric = MetaDataUtils.getMetric(capabilityDomain, >- _selectedProperty); >- _metricsViewer.setInput(metric); >- } >- }); >- } >- >- /** >- * Refreshes the section. >- */ >- public void refresh() >- { >- } >- >- /** >- * Initializes control listeners. >- */ >- public void hookAllListeners() >- { >- } >- >- /** >- * Handle viewer selection changed. >- */ >- public void selectionChanged(SelectionChangedEvent event) >- { >- _metricsViewer.getTable().setEnabled(_selectedProperty != null && !_editor.isReadOnly()); >- if (_selectedProperty != null) >- { >- FormMetric metric = createMetricFromProperty(); >- _metricsViewer.setInput(metric); >- } >- } >- >- private FormMetric createMetricFromProperty() >- { >- CapabilityDomain capabilityDomain = _editor.getCapabilityDomain(); >- FormMetric metric = MetaDataUtils.getMetric(capabilityDomain, >- _selectedProperty); >- return metric; >- } >- >- /** >- * Update its selected object. >- */ >- public void setSelectedObject(Object object) >- { >- _selectedProperty = null; >- if (object instanceof Property) >- { >- _selectedProperty = (Property) object; >- } >- } >- >- /** >- * Enable or disable the section based on parameter passed. >- */ >- public void enable(boolean enabled) >- { >- _metricsViewer.getTable().setEnabled(enabled); >- } >+ /** >+ * Enable or disable the section based on parameter passed. >+ */ >+ public void enable(boolean enabled) >+ { >+ _metricsViewer.getTable().setEnabled(enabled); >+ } > } > > class XsdDurationCellEditor extends DialogCellEditor > { > >- public XsdDurationCellEditor(Table table) >- { >- super(table); >- } >- >- protected Object openDialogBox(Control cellEditorWindow) >- { >- String duration = (String) doGetValue(); >- if (duration == null) >- duration = "PT1M"; >- XsdDurationDialog dlg = new XsdDurationDialog(cellEditorWindow >- .getShell(), duration); >- if (dlg.open() == XsdDurationDialog.OK) >+ public XsdDurationCellEditor(Table table) > { >- return dlg.getXsdDuration(); >+ super(table); > } > >- return null; >- } >+ protected Object openDialogBox(Control cellEditorWindow) >+ { >+ String duration = (String) doGetValue(); >+ if (duration == null) >+ duration = "PT1M"; >+ XsdDurationDialog dlg = new XsdDurationDialog(cellEditorWindow >+ .getShell(), duration); >+ if (dlg.open() == XsdDurationDialog.OK) >+ { >+ return dlg.getXsdDuration(); >+ } >+ >+ return null; >+ } > > } > > class MetricsContentProvider implements IStructuredContentProvider > { > >- private final Shell shell; >+ private final Shell shell; >+ >+ public MetricsContentProvider(Shell _shell) >+ { >+ this.shell = _shell; >+ } >+ >+ public Object[] getElements(Object element) >+ { >+ if (element instanceof FormMetric) >+ { >+ return new Object[] { element }; >+ } >+ throw new IllegalStateException(NLS.bind( >+ Messages.UNEXPECTED_TYPE_ERROR_, element.getClass())); >+ } >+ >+ public void dispose() >+ { >+ } >+ >+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) >+ { >+ } > >- public MetricsContentProvider(Shell _shell) >- { >- this.shell = _shell; >- } >- >- public Object[] getElements(Object element) >- { >- if (element instanceof FormMetric) >- { >- return new Object[] { element }; >- } >- throw new IllegalStateException(NLS.bind(Messages.UNEXPECTED_TYPE_ERROR_, element.getClass())); >- } >- >- public void dispose() >- { >- } >- >- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) >- { >- } >- >- public IBaseLabelProvider getLabelProvider() >- { >- return new MetricsLabelProvider(shell); >- } >+ public IBaseLabelProvider getLabelProvider() >+ { >+ return new MetricsLabelProvider(shell); >+ } > } > > class MetricsLabelProvider extends LabelProvider implements ITableLabelProvider > { > >- public MetricsLabelProvider(Shell _shell) >- { >- } >- >- public Image getColumnImage(Object element, int columnIndex) >- { >- return null; >- } >- >- public String getColumnText(Object element, int columnIndex) >- { >- if (element instanceof FormMetric) >+ public MetricsLabelProvider(Shell _shell) >+ { >+ } >+ >+ public Image getColumnImage(Object element, int columnIndex) >+ { >+ return null; >+ } >+ >+ public String getColumnText(Object element, int columnIndex) > { >- FormMetric metric = (FormMetric) element; >- return metric.getColumnText(columnIndex); >+ if (element instanceof FormMetric) >+ { >+ FormMetric metric = (FormMetric) element; >+ return metric.getColumnText(columnIndex); >+ } >+ throw new IllegalStateException(NLS.bind( >+ Messages.UNEXPECTED_TYPE_ERROR_, element.getClass())); > } >- throw new IllegalStateException(NLS.bind(Messages.UNEXPECTED_TYPE_ERROR_, element.getClass())); >- } > } >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/property/internal/NewPropertyDialog.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.editor.capability/src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/property/internal/NewPropertyDialog.java,v >retrieving revision 1.5 >diff -u -r1.5 NewPropertyDialog.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/property/internal/NewPropertyDialog.java 9 Jan 2007 19:51:43 -0000 1.5 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/property/internal/NewPropertyDialog.java 20 Jan 2007 13:33:41 -0000 >@@ -60,627 +60,631 @@ > public class NewPropertyDialog extends Dialog > { > >- private final String _title; >+ private final String _title; > >- private Text _propertyName; >+ private Text _propertyName; > >- private TreeViewer _dataTypeViewer; >+ private TreeViewer _dataTypeViewer; > >- private Button _importButton; >+ private Button _importButton; > >- private Button _writableButton; >- >- private Button _readonlyButton; >- >- private String _modifiability; >- >- private String _mutability; >- >- private Button _propConstant; >- >- private Button _propAppendable; >- >- private Button _propMutable; >- >- private Button _button1to1; >- >- private Button _button0to1; >- >- private Button _button0toN; >- >- private Button _button1toN; >- >- private Button _buttonXtoY; >- >- private Text _propMinOccurs; >- >- private Text _propMaxOccurs; >- >- private Listener _minMaxListener; >- >- private XSDElementDeclaration _property; >- >- private CapabilityDomain _capabilityDomain; >- >- private int _minoccurs; >- >- private int _maxoccurs; >- >- private DataType _dataType; >- >- /** >- * Creates the dialog for new property. >- * >- * @param parentShell >- * Shell. >- * >- * @param dialogTitle >- * Title for this dialog. >- * >- * @param capabilityDomain >- * Capability domain for capability editor. >- * >- */ >- public NewPropertyDialog(Shell parentShell, String dialogTitle, >- CapabilityDomain capabilityDomain) >- { >- super(parentShell); >- setShellStyle(getShellStyle() | SWT.RESIZE); >- _title = dialogTitle; >- _capabilityDomain = capabilityDomain; >- _property = XSDFactory.eINSTANCE.createXSDElementDeclaration(); >- } >- >- /** >- * Configure the shell. >- */ >- protected void configureShell(Shell shell) >- { >- super.configureShell(shell); >- if (_title != null) >- shell.setText(_title); >- } >- >- /** >- * Creates the dialog area. >- */ >- protected Control createDialogArea(Composite parent) >- { >- Composite container = (Composite) super.createDialogArea(parent); >- GridLayout layout = new GridLayout(2, true); >- container.setLayout(layout); >- >- Composite lhsComposite = new Composite(container, SWT.NONE); >- layout = new GridLayout(1, true); >- layout.verticalSpacing = 5; >- lhsComposite.setLayout(layout); >- GridData gd = new GridData(); >- gd.grabExcessHorizontalSpace = true; >- lhsComposite.setLayoutData(gd); >- >- Composite rhsComposite = new Composite(container, SWT.NONE); >- layout = new GridLayout(1, true); >- layout.verticalSpacing = 5; >- rhsComposite.setLayout(layout); >- gd = new GridData(); >- gd.grabExcessHorizontalSpace = true; >- rhsComposite.setLayoutData(gd); >- >- createLeftCompositeArea(lhsComposite); >- createRightCompositeArea(rhsComposite); >- >- initializeControls(); >- hookAllListeners(); >- >- applyDialogFont(container); >- return container; >- } >- >- private void createLeftCompositeArea(Composite lhsComposite) >- { >- Label propertyNameLabel = new Label(lhsComposite, SWT.NONE); >- propertyNameLabel.setText(Messages.PROP_NAME); >- GridData gd = new GridData(); >- gd.horizontalSpan = ((GridLayout) lhsComposite.getLayout()).numColumns; >- propertyNameLabel.setLayoutData(gd); >- >- _propertyName = new Text(lhsComposite, SWT.SINGLE | SWT.BORDER); >- gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); >- gd.horizontalSpan = ((GridLayout) lhsComposite.getLayout()).numColumns; >- _propertyName.setLayoutData(gd); >- >- Label propertyTypeLabel = new Label(lhsComposite, SWT.NONE); >- propertyTypeLabel.setText(Messages.PROP_TYPE); >- gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); >- gd.horizontalSpan = ((GridLayout) lhsComposite.getLayout()).numColumns; >- propertyTypeLabel.setLayoutData(gd); >- >- _dataTypeViewer = new TreeViewer(lhsComposite, SWT.BORDER | SWT.H_SCROLL >- | SWT.V_SCROLL); >- GridData data = new GridData(); >- data.horizontalSpan = ((GridLayout) lhsComposite.getLayout()).numColumns; >- data.heightHint = 220; >- data.widthHint = 200; >- data.horizontalAlignment = GridData.FILL; >- data.verticalAlignment = GridData.FILL; >- data.grabExcessHorizontalSpace = true; >- data.grabExcessVerticalSpace = true; >- _dataTypeViewer.getControl().setLayoutData(data); >- DataTypesContentProvider contentProvider = new DataTypesContentProvider(); >- _dataTypeViewer.setContentProvider(contentProvider); >- _dataTypeViewer.setLabelProvider(contentProvider.getLabelProvider()); >- _dataTypeViewer.getControl().setData(FormToolkit.KEY_DRAW_BORDER, >- FormToolkit.TREE_BORDER); >- >- _importButton = new Button(lhsComposite, SWT.PUSH); >- _importButton.setText(org.eclipse.tptp.wsdm.tooling.nls.messages.capability.internal.Messages.IMPORT_COMPLEX_DATA_TYPE); >- } >- >- private void createRightCompositeArea(Composite rhsComposite) >- { >- Group modifiabilityGroup = new Group(rhsComposite, SWT.SHADOW_IN); >- GridLayout layout = new GridLayout(1, true); >- modifiabilityGroup.setLayout(layout); >- GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); >- gd.grabExcessHorizontalSpace = true; >- modifiabilityGroup.setLayoutData(gd); >- modifiabilityGroup.setText(Messages.MAKE_THIS_PROP_LABEL); >- _writableButton = new Button(modifiabilityGroup, SWT.RADIO); >- gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); >- gd.horizontalSpan = ((GridLayout) modifiabilityGroup.getLayout()).numColumns; >- _writableButton.setLayoutData(gd); >- _writableButton.setText(Messages.WRITABLE); >- _readonlyButton = new Button(modifiabilityGroup, SWT.RADIO); >- gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); >- gd.horizontalSpan = ((GridLayout) modifiabilityGroup.getLayout()).numColumns; >- _readonlyButton.setLayoutData(gd); >- _readonlyButton.setText(Messages.READ_ONLY); >- >- Group mutability = new Group(rhsComposite, SWT.SHADOW_IN); >- layout = new GridLayout(1, true); >- mutability.setLayout(layout); >- gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); >- gd.grabExcessHorizontalSpace = true; >- mutability.setLayoutData(gd); >- mutability.setText(Messages.MUTABILITY); >- _propMutable = new Button(mutability, SWT.RADIO); >- _propMutable.setText(Messages.MUTABLE); >- gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); >- gd.horizontalSpan = ((GridLayout) mutability.getLayout()).numColumns; >- _propMutable.setLayoutData(gd); >- _propConstant = new Button(mutability, SWT.RADIO); >- _propConstant.setText(Messages.CONSTANT); >- gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); >- gd.horizontalSpan = ((GridLayout) mutability.getLayout()).numColumns; >- _propConstant.setLayoutData(gd); >- _propAppendable = new Button(mutability, SWT.RADIO); >- _propAppendable.setText(Messages.APPENDABLE); >- gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); >- gd.horizontalSpan = ((GridLayout) mutability.getLayout()).numColumns; >- _propAppendable.setLayoutData(gd); >- >- Group cardinality = new Group(rhsComposite, SWT.SHADOW_IN); >- layout = new GridLayout(1, true); >- cardinality.setLayout(layout); >- gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); >- gd.grabExcessHorizontalSpace = true; >- cardinality.setLayoutData(gd); >- cardinality.setText(Messages.CARDINALITY); >- _button1to1 = new Button(cardinality, SWT.RADIO); >- _button1to1.setText(Messages.ALWAYS_PRESENT_LABEL); >- gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); >- gd.horizontalSpan = ((GridLayout) cardinality.getLayout()).numColumns; >- _button1to1.setLayoutData(gd); >- _button0to1 = new Button(cardinality, SWT.RADIO); >- _button0to1.setText(Messages.OPTIONAL_LABEL); >- gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); >- gd.horizontalSpan = ((GridLayout) cardinality.getLayout()).numColumns; >- _button0to1.setLayoutData(gd); >- _button0toN = new Button(cardinality, SWT.RADIO); >- _button0toN.setText(Messages.ZERO_TO_UNBOUNDED_LABEL); >- gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); >- gd.horizontalSpan = ((GridLayout) cardinality.getLayout()).numColumns; >- _button0toN.setLayoutData(gd); >- _button1toN = new Button(cardinality, SWT.RADIO); >- _button1toN.setText(Messages.ONE_TO_UNBOUNDED_LABEL); >- gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); >- gd.horizontalSpan = ((GridLayout) cardinality.getLayout()).numColumns; >- _button1toN.setLayoutData(gd); >- _buttonXtoY = new Button(cardinality, SWT.RADIO); >- _buttonXtoY.setText(Messages.OTHER_LABEL); >- gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); >- gd.horizontalSpan = ((GridLayout) cardinality.getLayout()).numColumns; >- _buttonXtoY.setLayoutData(gd); >- >- Composite otherComposite = new Composite(cardinality, SWT.NONE); >- layout = new GridLayout(5, false); >- otherComposite.setLayout(layout); >- >- Label label = new Label(otherComposite, SWT.NONE); >- label.setText(Messages.SQUARE_OPEN_BRACKET); >- gd = new GridData(); >- gd.horizontalSpan = 1; >- gd.horizontalIndent = 15; >- label.setLayoutData(gd); >- >- _propMinOccurs = new Text(otherComposite, SWT.SINGLE | SWT.BORDER); >- _propMinOccurs.setText(Messages.ZERO); >- gd = new GridData(); >- gd.horizontalSpan = 1; >- gd.widthHint = 40; >- gd.grabExcessHorizontalSpace = true; >- _propMinOccurs.setLayoutData(gd); >- >- label = new Label(otherComposite, SWT.NONE); >- label.setText(Messages.DOTS); >- gd = new GridData(); >- gd.horizontalSpan = 1; >- label.setLayoutData(gd); >- >- _propMaxOccurs = new Text(otherComposite, SWT.SINGLE | SWT.BORDER); >- _propMaxOccurs.setText(Messages.ONE); >- gd = new GridData(); >- gd.horizontalSpan = 1; >- gd.widthHint = 40; >- gd.grabExcessHorizontalSpace = true; >- _propMaxOccurs.setLayoutData(gd); >- >- label = new Label(otherComposite, SWT.NONE); >- label.setText(Messages.SQUARE_END_BRACKET); >- gd = new GridData(); >- gd.horizontalSpan = 1; >- label.setLayoutData(gd); >- } >- >- /** >- * Creates button bar. >- */ >- protected Control createButtonBar(Composite parent) >- { >- Control ret = super.createButtonBar(parent); >- return ret; >- } >- >- private void initializeControls() >- { >- NewNameGenerator nameGenerator = new NewNameGenerator("property"); >- String propName = nameGenerator.getNextName(); >- while (propertyAlreadyExists(propName)) >- { >- propName = nameGenerator.getNextName(); >- } >- >- _propertyName.setText(propName); >- >- DataTypesCollection instance = DataTypesCollection.getInstance(); >- DataTypeCategory[] categories = instance.getDataTypeCategories(false); >- _dataTypeViewer.setInput(Arrays.asList(categories)); >- _dataTypeViewer.refresh(); >- >- DataType stringDataType = instance.getDataType("string"); >- _dataTypeViewer.setSelection(new StructuredSelection(stringDataType), true); >- _writableButton.setSelection(true); >- _propMutable.setSelection(true); >- _propAppendable.setEnabled(false); >- _button1to1.setSelection(true); >- _propMinOccurs.setEnabled(false); >- _propMaxOccurs.setEnabled(false); >- _propertyName.setSelection(0, _propertyName.getCharCount()); >- } >- >- /** >- * Creates new property. >- */ >- protected void okPressed() >- { >- _property.setName(_propertyName.getText()); >- >- if (!validProperty()) >- { >- _propertyName.setSelection(0, _propertyName.getCharCount()); >- _propertyName.forceFocus(); >- return; >- } >- >- _dataType = (DataType) getSelectedViewerObject(); >- >- XSDSchema propertySchema = _capabilityDomain.getPropertySchema(); >- if (propertySchema == null) >- { >- propertySchema = createNewXSDSchema(); >- _capabilityDomain.setPropertySchema(propertySchema); >- } >- >- _modifiability = buildModifiabilityFromControls(); >- buildCardinalityFromControls(); >- _mutability = buildMutabilityFromControls(); >- >- super.okPressed(); >- } >- >- private Object getSelectedViewerObject(){ >- StructuredSelection ss = (StructuredSelection) _dataTypeViewer.getSelection(); >- Object[] selectedObjects = ss.toArray(); >- return selectedObjects[0]; >- } >- >- private XSDSchema createNewXSDSchema() >- { >- Capability capability = _capabilityDomain.getCapability(); >- String targetNamespace = capability.getNamespace(); >- XSDSchema propertySchema = XsdUtils.createNewXSDSchema(targetNamespace); >- Definition wsdlDefinition = _capabilityDomain.getDefinition(); >- String wsdlPath = WsdlUtils.getWSDLFileLocation(wsdlDefinition); >- String wsdlContainer = wsdlPath.substring(0, wsdlPath.lastIndexOf("/")); >- String capabilityName = capability.getName(); >- propertySchema.setSchemaLocation(wsdlContainer + "/" + capabilityName >- + ".xsd"); >- >- return propertySchema; >- } >- >- private boolean propertyAlreadyExists(String name) >- { >- Capability model = _capabilityDomain.getCapability(); >- if (CapUtils.getInstancesOfProperty(model, name) >= 1) >- return true; >- return false; >- } >- >- private boolean validProperty() >- { >- // Check for duplicate property name >- if (propertyAlreadyExists(_property.getName())) >- { >- MessageDialog.openError(getShell(), "ERROR", >- Messages.PROP_ALREADY_EXISTS_WARN_); >- return false; >- } >- // Check for valid java identifier >- String msg = CapUtils.validateJavaIdentifier(_property.getName()); >- if (msg != null) >- { >- MessageDialog.openError(getShell(), "ERROR", >- Messages.PROP_NOT_VALID_JAVA_ID_WARN_); >- return false; >- } >- return true; >- } >- >- private String buildMutabilityFromControls() >- { >- if (_propConstant.getSelection()) >- { >- return "constant"; >- } >- else if (_propAppendable.getSelection()) >- { >- return "appendable"; >- } >- else if (_propMutable.getSelection()) >- { >- return "mutable"; >- } >- return "unknown"; >- } >- >- private String buildModifiabilityFromControls() >- { >- if (_readonlyButton.getSelection()) >- return "read-only"; >- return "read-write"; >- } >- >- private void enableDisableAppendable() >- { >- _propAppendable.setEnabled(true); >- if (_button1to1.getSelection() || _button0to1.getSelection()) >- { >- _propAppendable.setSelection(false); >- _propAppendable.setEnabled(false); >- } >- >- } >- >- private void enableDisableMinMax() >- { >- _propMinOccurs.setEnabled(_buttonXtoY.getSelection()); >- _propMaxOccurs.setEnabled(_buttonXtoY.getSelection()); >- if (_buttonXtoY.getSelection()) >- { >- if (_propMinOccurs.getText().trim().equals("") >- || _propMaxOccurs.getText().trim().equals("")) >- getButton(IDialogConstants.OK_ID).setEnabled(false); >- } >- else >- getButton(IDialogConstants.OK_ID).setEnabled(true); >- if (_propertyName.getText().trim().equals("")) >- getButton(IDialogConstants.OK_ID).setEnabled(false); >- } >- >- private void buildCardinalityFromControls() >- { >- if (_button1to1.getSelection()) >- { >- _minoccurs = _maxoccurs = 1; >- } >- else if (_button0to1.getSelection()) >- { >- _minoccurs = 0; >- _maxoccurs = 1; >- } >- else if (_button0toN.getSelection()) >- { >- _minoccurs = 0; >- _maxoccurs = -1; >- } >- else if (_button1toN.getSelection()) >- { >- _minoccurs = 1; >- _maxoccurs = -1; >- } >- else >- { >- try >- { >- _minoccurs = Integer.parseInt(_propMinOccurs.getText()); >- _maxoccurs = Integer.parseInt(_propMaxOccurs.getText()); >- } catch (NumberFormatException nfe) >- { >- _minoccurs = 1; >- _maxoccurs = 1; >- WsdmToolingLog.logError(Messages.FAILED_TO_PARSE_MIN_MAX_FIELDS_ERROR_ + " ", >- nfe); >- } >- } >- } >- >- /** >- * >- * @return New property. >- */ >- public XSDElementDeclaration getProperty() >- { >- return _property; >- } >- >- private void hookAllListeners() >- { >- _propertyName.addModifyListener(new ModifyListener() >+ private Button _writableButton; >+ >+ private Button _readonlyButton; >+ >+ private String _modifiability; >+ >+ private String _mutability; >+ >+ private Button _propConstant; >+ >+ private Button _propAppendable; >+ >+ private Button _propMutable; >+ >+ private Button _button1to1; >+ >+ private Button _button0to1; >+ >+ private Button _button0toN; >+ >+ private Button _button1toN; >+ >+ private Button _buttonXtoY; >+ >+ private Text _propMinOccurs; >+ >+ private Text _propMaxOccurs; >+ >+ private Listener _minMaxListener; >+ >+ private XSDElementDeclaration _property; >+ >+ private CapabilityDomain _capabilityDomain; >+ >+ private int _minoccurs; >+ >+ private int _maxoccurs; >+ >+ private DataType _dataType; >+ >+ /** >+ * Creates the dialog for new property. >+ * >+ * @param parentShell >+ * Shell. >+ * >+ * @param dialogTitle >+ * Title for this dialog. >+ * >+ * @param capabilityDomain >+ * Capability domain for capability editor. >+ * >+ */ >+ public NewPropertyDialog(Shell parentShell, String dialogTitle, >+ CapabilityDomain capabilityDomain) >+ { >+ super(parentShell); >+ setShellStyle(getShellStyle() | SWT.RESIZE); >+ _title = dialogTitle; >+ _capabilityDomain = capabilityDomain; >+ _property = XSDFactory.eINSTANCE.createXSDElementDeclaration(); >+ } >+ >+ /** >+ * Configure the shell. >+ */ >+ protected void configureShell(Shell shell) >+ { >+ super.configureShell(shell); >+ if (_title != null) >+ shell.setText(_title); >+ } >+ >+ /** >+ * Creates the dialog area. >+ */ >+ protected Control createDialogArea(Composite parent) >+ { >+ Composite container = (Composite) super.createDialogArea(parent); >+ GridLayout layout = new GridLayout(2, true); >+ container.setLayout(layout); >+ >+ Composite lhsComposite = new Composite(container, SWT.NONE); >+ layout = new GridLayout(1, true); >+ layout.verticalSpacing = 5; >+ lhsComposite.setLayout(layout); >+ GridData gd = new GridData(); >+ gd.grabExcessHorizontalSpace = true; >+ lhsComposite.setLayoutData(gd); >+ >+ Composite rhsComposite = new Composite(container, SWT.NONE); >+ layout = new GridLayout(1, true); >+ layout.verticalSpacing = 5; >+ rhsComposite.setLayout(layout); >+ gd = new GridData(); >+ gd.grabExcessHorizontalSpace = true; >+ rhsComposite.setLayoutData(gd); >+ >+ createLeftCompositeArea(lhsComposite); >+ createRightCompositeArea(rhsComposite); >+ >+ initializeControls(); >+ hookAllListeners(); >+ >+ applyDialogFont(container); >+ return container; >+ } >+ >+ private void createLeftCompositeArea(Composite lhsComposite) >+ { >+ Label propertyNameLabel = new Label(lhsComposite, SWT.NONE); >+ propertyNameLabel.setText(Messages.PROP_NAME); >+ GridData gd = new GridData(); >+ gd.horizontalSpan = ((GridLayout) lhsComposite.getLayout()).numColumns; >+ propertyNameLabel.setLayoutData(gd); >+ >+ _propertyName = new Text(lhsComposite, SWT.SINGLE | SWT.BORDER); >+ gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); >+ gd.horizontalSpan = ((GridLayout) lhsComposite.getLayout()).numColumns; >+ _propertyName.setLayoutData(gd); >+ >+ Label propertyTypeLabel = new Label(lhsComposite, SWT.NONE); >+ propertyTypeLabel.setText(Messages.PROP_TYPE); >+ gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); >+ gd.horizontalSpan = ((GridLayout) lhsComposite.getLayout()).numColumns; >+ propertyTypeLabel.setLayoutData(gd); >+ >+ _dataTypeViewer = new TreeViewer(lhsComposite, SWT.BORDER >+ | SWT.H_SCROLL | SWT.V_SCROLL); >+ GridData data = new GridData(); >+ data.horizontalSpan = ((GridLayout) lhsComposite.getLayout()).numColumns; >+ data.heightHint = 220; >+ data.widthHint = 200; >+ data.horizontalAlignment = GridData.FILL; >+ data.verticalAlignment = GridData.FILL; >+ data.grabExcessHorizontalSpace = true; >+ data.grabExcessVerticalSpace = true; >+ _dataTypeViewer.getControl().setLayoutData(data); >+ DataTypesContentProvider contentProvider = new DataTypesContentProvider(); >+ _dataTypeViewer.setContentProvider(contentProvider); >+ _dataTypeViewer.setLabelProvider(contentProvider.getLabelProvider()); >+ _dataTypeViewer.getControl().setData(FormToolkit.KEY_DRAW_BORDER, >+ FormToolkit.TREE_BORDER); >+ >+ _importButton = new Button(lhsComposite, SWT.PUSH); >+ _importButton >+ .setText(org.eclipse.tptp.wsdm.tooling.nls.messages.capability.internal.Messages.IMPORT_COMPLEX_DATA_TYPE); >+ } >+ >+ private void createRightCompositeArea(Composite rhsComposite) >+ { >+ Group modifiabilityGroup = new Group(rhsComposite, SWT.SHADOW_IN); >+ GridLayout layout = new GridLayout(1, true); >+ modifiabilityGroup.setLayout(layout); >+ GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); >+ gd.grabExcessHorizontalSpace = true; >+ modifiabilityGroup.setLayoutData(gd); >+ modifiabilityGroup.setText(Messages.MAKE_THIS_PROP_LABEL); >+ _writableButton = new Button(modifiabilityGroup, SWT.RADIO); >+ gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); >+ gd.horizontalSpan = ((GridLayout) modifiabilityGroup.getLayout()).numColumns; >+ _writableButton.setLayoutData(gd); >+ _writableButton.setText(Messages.WRITABLE); >+ _readonlyButton = new Button(modifiabilityGroup, SWT.RADIO); >+ gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); >+ gd.horizontalSpan = ((GridLayout) modifiabilityGroup.getLayout()).numColumns; >+ _readonlyButton.setLayoutData(gd); >+ _readonlyButton.setText(Messages.READ_ONLY); >+ >+ Group mutability = new Group(rhsComposite, SWT.SHADOW_IN); >+ layout = new GridLayout(1, true); >+ mutability.setLayout(layout); >+ gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); >+ gd.grabExcessHorizontalSpace = true; >+ mutability.setLayoutData(gd); >+ mutability.setText(Messages.MUTABILITY); >+ _propMutable = new Button(mutability, SWT.RADIO); >+ _propMutable.setText(Messages.MUTABLE); >+ gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); >+ gd.horizontalSpan = ((GridLayout) mutability.getLayout()).numColumns; >+ _propMutable.setLayoutData(gd); >+ _propConstant = new Button(mutability, SWT.RADIO); >+ _propConstant.setText(Messages.CONSTANT); >+ gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); >+ gd.horizontalSpan = ((GridLayout) mutability.getLayout()).numColumns; >+ _propConstant.setLayoutData(gd); >+ _propAppendable = new Button(mutability, SWT.RADIO); >+ _propAppendable.setText(Messages.APPENDABLE); >+ gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); >+ gd.horizontalSpan = ((GridLayout) mutability.getLayout()).numColumns; >+ _propAppendable.setLayoutData(gd); >+ >+ Group cardinality = new Group(rhsComposite, SWT.SHADOW_IN); >+ layout = new GridLayout(1, true); >+ cardinality.setLayout(layout); >+ gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); >+ gd.grabExcessHorizontalSpace = true; >+ cardinality.setLayoutData(gd); >+ cardinality.setText(Messages.CARDINALITY); >+ _button1to1 = new Button(cardinality, SWT.RADIO); >+ _button1to1.setText(Messages.ALWAYS_PRESENT_LABEL); >+ gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); >+ gd.horizontalSpan = ((GridLayout) cardinality.getLayout()).numColumns; >+ _button1to1.setLayoutData(gd); >+ _button0to1 = new Button(cardinality, SWT.RADIO); >+ _button0to1.setText(Messages.OPTIONAL_LABEL); >+ gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); >+ gd.horizontalSpan = ((GridLayout) cardinality.getLayout()).numColumns; >+ _button0to1.setLayoutData(gd); >+ _button0toN = new Button(cardinality, SWT.RADIO); >+ _button0toN.setText(Messages.ZERO_TO_UNBOUNDED_LABEL); >+ gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); >+ gd.horizontalSpan = ((GridLayout) cardinality.getLayout()).numColumns; >+ _button0toN.setLayoutData(gd); >+ _button1toN = new Button(cardinality, SWT.RADIO); >+ _button1toN.setText(Messages.ONE_TO_UNBOUNDED_LABEL); >+ gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); >+ gd.horizontalSpan = ((GridLayout) cardinality.getLayout()).numColumns; >+ _button1toN.setLayoutData(gd); >+ _buttonXtoY = new Button(cardinality, SWT.RADIO); >+ _buttonXtoY.setText(Messages.OTHER_LABEL); >+ gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); >+ gd.horizontalSpan = ((GridLayout) cardinality.getLayout()).numColumns; >+ _buttonXtoY.setLayoutData(gd); >+ >+ Composite otherComposite = new Composite(cardinality, SWT.NONE); >+ layout = new GridLayout(5, false); >+ otherComposite.setLayout(layout); >+ >+ Label label = new Label(otherComposite, SWT.NONE); >+ label.setText(Messages.SQUARE_OPEN_BRACKET); >+ gd = new GridData(); >+ gd.horizontalSpan = 1; >+ gd.horizontalIndent = 15; >+ label.setLayoutData(gd); >+ >+ _propMinOccurs = new Text(otherComposite, SWT.SINGLE | SWT.BORDER); >+ _propMinOccurs.setText(Messages.ZERO); >+ gd = new GridData(); >+ gd.horizontalSpan = 1; >+ gd.widthHint = 40; >+ gd.grabExcessHorizontalSpace = true; >+ _propMinOccurs.setLayoutData(gd); >+ >+ label = new Label(otherComposite, SWT.NONE); >+ label.setText(Messages.DOTS); >+ gd = new GridData(); >+ gd.horizontalSpan = 1; >+ label.setLayoutData(gd); >+ >+ _propMaxOccurs = new Text(otherComposite, SWT.SINGLE | SWT.BORDER); >+ _propMaxOccurs.setText(Messages.ONE); >+ gd = new GridData(); >+ gd.horizontalSpan = 1; >+ gd.widthHint = 40; >+ gd.grabExcessHorizontalSpace = true; >+ _propMaxOccurs.setLayoutData(gd); >+ >+ label = new Label(otherComposite, SWT.NONE); >+ label.setText(Messages.SQUARE_END_BRACKET); >+ gd = new GridData(); >+ gd.horizontalSpan = 1; >+ label.setLayoutData(gd); >+ } >+ >+ /** >+ * Creates button bar. >+ */ >+ protected Control createButtonBar(Composite parent) >+ { >+ Control ret = super.createButtonBar(parent); >+ return ret; >+ } >+ >+ private void initializeControls() >+ { >+ NewNameGenerator nameGenerator = new NewNameGenerator("property"); >+ String propName = nameGenerator.getNextName(); >+ while (propertyAlreadyExists(propName)) >+ { >+ propName = nameGenerator.getNextName(); >+ } >+ >+ _propertyName.setText(propName); >+ >+ DataTypesCollection instance = DataTypesCollection.getInstance(); >+ DataTypeCategory[] categories = instance.getDataTypeCategories(false); >+ _dataTypeViewer.setInput(Arrays.asList(categories)); >+ _dataTypeViewer.refresh(); >+ >+ DataType stringDataType = instance.getDataType("string"); >+ _dataTypeViewer.setSelection(new StructuredSelection(stringDataType), >+ true); >+ _writableButton.setSelection(true); >+ _propMutable.setSelection(true); >+ _propAppendable.setEnabled(false); >+ _button1to1.setSelection(true); >+ _propMinOccurs.setEnabled(false); >+ _propMaxOccurs.setEnabled(false); >+ _propertyName.setSelection(0, _propertyName.getCharCount()); >+ } >+ >+ /** >+ * Creates new property. >+ */ >+ protected void okPressed() > { >+ _property.setName(_propertyName.getText()); > >- public void modifyText(ModifyEvent e) >- { >- if (_propertyName.getText().trim().equals("")) >- getButton(IDialogConstants.OK_ID).setEnabled(false); >- else >+ if (!validProperty()) >+ { >+ _propertyName.setSelection(0, _propertyName.getCharCount()); >+ _propertyName.forceFocus(); >+ return; >+ } >+ >+ _dataType = (DataType) getSelectedViewerObject(); >+ >+ XSDSchema propertySchema = _capabilityDomain.getPropertySchema(); >+ if (propertySchema == null) >+ { >+ propertySchema = createNewXSDSchema(); >+ _capabilityDomain.setPropertySchema(propertySchema); >+ } >+ >+ _modifiability = buildModifiabilityFromControls(); >+ buildCardinalityFromControls(); >+ _mutability = buildMutabilityFromControls(); >+ >+ super.okPressed(); >+ } >+ >+ private Object getSelectedViewerObject() >+ { >+ StructuredSelection ss = (StructuredSelection) _dataTypeViewer >+ .getSelection(); >+ Object[] selectedObjects = ss.toArray(); >+ return selectedObjects[0]; >+ } >+ >+ private XSDSchema createNewXSDSchema() >+ { >+ Capability capability = _capabilityDomain.getCapability(); >+ String targetNamespace = capability.getNamespace(); >+ XSDSchema propertySchema = XsdUtils.createNewXSDSchema(targetNamespace); >+ Definition wsdlDefinition = capability.getDefinition(); >+ String wsdlPath = WsdlUtils.getWSDLFileLocation(wsdlDefinition); >+ String wsdlContainer = wsdlPath.substring(0, wsdlPath.lastIndexOf("/")); >+ String capabilityName = capability.getName(); >+ propertySchema.setSchemaLocation(wsdlContainer + "/" + capabilityName >+ + ".xsd"); >+ >+ return propertySchema; >+ } >+ >+ private boolean propertyAlreadyExists(String name) >+ { >+ Capability model = _capabilityDomain.getCapability(); >+ if (CapUtils.getInstancesOfProperty(model, name) >= 1) >+ return true; >+ return false; >+ } >+ >+ private boolean validProperty() >+ { >+ // Check for duplicate property name >+ if (propertyAlreadyExists(_property.getName())) >+ { >+ MessageDialog.openError(getShell(), "ERROR", >+ Messages.PROP_ALREADY_EXISTS_WARN_); >+ return false; >+ } >+ // Check for valid java identifier >+ String msg = CapUtils.validateJavaIdentifier(_property.getName()); >+ if (msg != null) >+ { >+ MessageDialog.openError(getShell(), "ERROR", >+ Messages.PROP_NOT_VALID_JAVA_ID_WARN_); >+ return false; >+ } >+ return true; >+ } >+ >+ private String buildMutabilityFromControls() >+ { >+ if (_propConstant.getSelection()) >+ { >+ return "constant"; >+ } >+ else if (_propAppendable.getSelection()) >+ { >+ return "appendable"; >+ } >+ else if (_propMutable.getSelection()) >+ { >+ return "mutable"; >+ } >+ return "unknown"; >+ } >+ >+ private String buildModifiabilityFromControls() >+ { >+ if (_readonlyButton.getSelection()) >+ return "read-only"; >+ return "read-write"; >+ } >+ >+ private void enableDisableAppendable() >+ { >+ _propAppendable.setEnabled(true); >+ if (_button1to1.getSelection() || _button0to1.getSelection()) >+ { >+ _propAppendable.setSelection(false); >+ _propAppendable.setEnabled(false); >+ } >+ >+ } >+ >+ private void enableDisableMinMax() >+ { >+ _propMinOccurs.setEnabled(_buttonXtoY.getSelection()); >+ _propMaxOccurs.setEnabled(_buttonXtoY.getSelection()); >+ if (_buttonXtoY.getSelection()) > { >- if (_buttonXtoY.getSelection()) >- { > if (_propMinOccurs.getText().trim().equals("") >- || _propMaxOccurs.getText().trim().equals("")) >- getButton(IDialogConstants.OK_ID).setEnabled(false); >- else >- getButton(IDialogConstants.OK_ID).setEnabled(true); >- } >- else >+ || _propMaxOccurs.getText().trim().equals("")) >+ getButton(IDialogConstants.OK_ID).setEnabled(false); >+ } >+ else > getButton(IDialogConstants.OK_ID).setEnabled(true); >+ if (_propertyName.getText().trim().equals("")) >+ getButton(IDialogConstants.OK_ID).setEnabled(false); >+ } >+ >+ private void buildCardinalityFromControls() >+ { >+ if (_button1to1.getSelection()) >+ { >+ _minoccurs = _maxoccurs = 1; >+ } >+ else if (_button0to1.getSelection()) >+ { >+ _minoccurs = 0; >+ _maxoccurs = 1; >+ } >+ else if (_button0toN.getSelection()) >+ { >+ _minoccurs = 0; >+ _maxoccurs = -1; >+ } >+ else if (_button1toN.getSelection()) >+ { >+ _minoccurs = 1; >+ _maxoccurs = -1; > } >+ else >+ { >+ try >+ { >+ _minoccurs = Integer.parseInt(_propMinOccurs.getText()); >+ _maxoccurs = Integer.parseInt(_propMaxOccurs.getText()); >+ } catch (NumberFormatException nfe) >+ { >+ _minoccurs = 1; >+ _maxoccurs = 1; >+ WsdmToolingLog.logError( >+ Messages.FAILED_TO_PARSE_MIN_MAX_FIELDS_ERROR_ + " ", >+ nfe); >+ } >+ } >+ } >+ >+ /** >+ * >+ * @return New property. >+ */ >+ public XSDElementDeclaration getProperty() >+ { >+ return _property; >+ } >+ >+ private void hookAllListeners() >+ { >+ _propertyName.addModifyListener(new ModifyListener() { >+ >+ public void modifyText(ModifyEvent e) >+ { >+ if (_propertyName.getText().trim().equals("")) >+ getButton(IDialogConstants.OK_ID).setEnabled(false); >+ else >+ { >+ if (_buttonXtoY.getSelection()) >+ { >+ if (_propMinOccurs.getText().trim().equals("") >+ || _propMaxOccurs.getText().trim().equals("")) >+ getButton(IDialogConstants.OK_ID).setEnabled(false); >+ else >+ getButton(IDialogConstants.OK_ID).setEnabled(true); >+ } >+ else >+ getButton(IDialogConstants.OK_ID).setEnabled(true); >+ } >+ >+ } >+ }); >+ >+ _dataTypeViewer >+ .addSelectionChangedListener(new ISelectionChangedListener() { >+ public void selectionChanged(SelectionChangedEvent event) >+ { >+ getButton(IDialogConstants.OK_ID).setEnabled(true); >+ Object selectedObject = getSelectedViewerObject(); >+ if (!(selectedObject instanceof DataType)) >+ getButton(IDialogConstants.OK_ID).setEnabled(false); >+ } >+ }); >+ >+ _propMinOccurs.addModifyListener(new ModifyListener() { >+ >+ public void modifyText(ModifyEvent e) >+ { >+ if (_propMinOccurs.getText().trim().equals("") >+ || _propMaxOccurs.getText().trim().equals("")) >+ getButton(IDialogConstants.OK_ID).setEnabled(false); >+ else if (!_propertyName.getText().trim().equals("")) >+ getButton(IDialogConstants.OK_ID).setEnabled(true); >+ } >+ }); >+ _propMaxOccurs.addModifyListener(new ModifyListener() { >+ >+ public void modifyText(ModifyEvent e) >+ { >+ if (_propMinOccurs.getText().trim().equals("") >+ || _propMaxOccurs.getText().trim().equals("")) >+ getButton(IDialogConstants.OK_ID).setEnabled(false); >+ else if (!_propertyName.getText().trim().equals("")) >+ getButton(IDialogConstants.OK_ID).setEnabled(true); >+ } >+ }); >+ _minMaxListener = new Listener() { >+ public void handleEvent(Event event) >+ { >+ enableDisableAppendable(); >+ enableDisableMinMax(); >+ } >+ }; >+ >+ _button1to1.addListener(SWT.Selection, _minMaxListener); >+ _button0to1.addListener(SWT.Selection, _minMaxListener); >+ _button0toN.addListener(SWT.Selection, _minMaxListener); >+ _button1toN.addListener(SWT.Selection, _minMaxListener); >+ _buttonXtoY.addListener(SWT.Selection, _minMaxListener); >+ >+ _importButton.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) >+ { >+ importComplexTypes(); >+ } >+ }); >+ } >+ >+ private void importComplexTypes() >+ { >+ ImportComplexTypeAction action = new ImportComplexTypeAction(getShell()); >+ action.run(); >+ >+ _dataTypeViewer.refresh(); >+ >+ DataTypesCollection instance = DataTypesCollection.getInstance(); >+ DataType stringDataType = instance.getDataType("string"); >+ _dataTypeViewer.setSelection(new StructuredSelection(stringDataType), >+ true); >+ } >+ >+ /** >+ * >+ * @return MinOcuurs of new property. >+ */ >+ public int getMinOcuurs() >+ { >+ return _minoccurs; >+ } >+ >+ /** >+ * >+ * @return MaxOccurs of new property. >+ */ >+ public int getMaxOccurs() >+ { >+ return _maxoccurs; >+ } >+ >+ /** >+ * >+ * @return Modifiability of new property. >+ */ >+ public String getModifiability() >+ { >+ return _modifiability; >+ } >+ >+ /** >+ * >+ * @return Mutability of new property. >+ */ >+ public String getMutability() >+ { >+ return _mutability; >+ } >+ >+ /** >+ * Return the data type selected for new property >+ * >+ */ >+ public DataType getDataType() >+ { >+ return _dataType; >+ } > >- } >- }); >- >- _dataTypeViewer.addSelectionChangedListener(new ISelectionChangedListener(){ >- public void selectionChanged(SelectionChangedEvent event) { >- getButton(IDialogConstants.OK_ID).setEnabled(true); >- Object selectedObject = getSelectedViewerObject(); >- if(!(selectedObject instanceof DataType)) >- getButton(IDialogConstants.OK_ID).setEnabled(false); >- }}); >- >- _propMinOccurs.addModifyListener(new ModifyListener() >- { >- >- public void modifyText(ModifyEvent e) >- { >- if (_propMinOccurs.getText().trim().equals("") >- || _propMaxOccurs.getText().trim().equals("")) >- getButton(IDialogConstants.OK_ID).setEnabled(false); >- else if (!_propertyName.getText().trim().equals("")) >- getButton(IDialogConstants.OK_ID).setEnabled(true); >- } >- }); >- _propMaxOccurs.addModifyListener(new ModifyListener() >- { >- >- public void modifyText(ModifyEvent e) >- { >- if (_propMinOccurs.getText().trim().equals("") >- || _propMaxOccurs.getText().trim().equals("")) >- getButton(IDialogConstants.OK_ID).setEnabled(false); >- else if (!_propertyName.getText().trim().equals("")) >- getButton(IDialogConstants.OK_ID).setEnabled(true); >- } >- }); >- _minMaxListener = new Listener() >- { >- public void handleEvent(Event event) >- { >- enableDisableAppendable(); >- enableDisableMinMax(); >- } >- }; >- >- _button1to1.addListener(SWT.Selection, _minMaxListener); >- _button0to1.addListener(SWT.Selection, _minMaxListener); >- _button0toN.addListener(SWT.Selection, _minMaxListener); >- _button1toN.addListener(SWT.Selection, _minMaxListener); >- _buttonXtoY.addListener(SWT.Selection, _minMaxListener); >- >- _importButton.addSelectionListener(new SelectionAdapter() >- { >- public void widgetSelected(SelectionEvent e) >- { >- importComplexTypes(); >- } >- }); >- } >- >- private void importComplexTypes() >- { >- ImportComplexTypeAction action = new ImportComplexTypeAction(getShell()); >- action.run(); >- >- _dataTypeViewer.refresh(); >- >- DataTypesCollection instance = DataTypesCollection.getInstance(); >- DataType stringDataType = instance.getDataType("string"); >- _dataTypeViewer.setSelection(new StructuredSelection(stringDataType), true); >- } >- >- /** >- * >- * @return MinOcuurs of new property. >- */ >- public int getMinOcuurs() >- { >- return _minoccurs; >- } >- >- /** >- * >- * @return MaxOccurs of new property. >- */ >- public int getMaxOccurs() >- { >- return _maxoccurs; >- } >- >- /** >- * >- * @return Modifiability of new property. >- */ >- public String getModifiability() >- { >- return _modifiability; >- } >- >- /** >- * >- * @return Mutability of new property. >- */ >- public String getMutability() >- { >- return _mutability; >- } >- >- /** >- * Return the data type selected for new property >- * >- */ >- public DataType getDataType() >- { >- return _dataType; >- } >- > } // end class NewPropertyDialog >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/property/internal/ListSection.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.editor.capability/src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/property/internal/ListSection.java,v >retrieving revision 1.6 >diff -u -r1.6 ListSection.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/property/internal/ListSection.java 9 Jan 2007 19:51:43 -0000 1.6 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/property/internal/ListSection.java 20 Jan 2007 13:33:38 -0000 >@@ -65,329 +65,349 @@ > public class ListSection extends AbstractPageSection implements IViewerClient > { > >- private StructuredTreeViewer _properties; >+ private StructuredTreeViewer _properties; > >- private ResourcePropertiesContentProvider _provider; >+ private ResourcePropertiesContentProvider _provider; > >- private Button _addPropertyButton; >+ private Button _addPropertyButton; > >- private Button _editMetadataButton; >+ private Button _editMetadataButton; > >- private Button _removePropertyButton; >- >- private Label _errorLabel; >- >- private Object _selectedObject; >- >- private Composite _sectionClient; >- >- private Composite _buttonClient; >- >- /** >- * Creates the new object of this class. >- */ >- ListSection(CapabilityEditor editor, IUIPage propertyPage, >- ScrolledForm form, FormToolkit toolkit) >- { >- super(editor, propertyPage, form, toolkit); >- } >- >- /** >- * Creates the section. >- */ >- public void create() >- { >- _sectionClient = createSection(Messages.PROPERTIES, >- Messages.PROPS_USED, 1, 4); >- GridLayout layout = new GridLayout(2, false); >- layout.marginWidth = LAYOUT_MARGIN_WIDTH; >- layout.verticalSpacing = LAYOUT_VERTICAL_SPACING; >- _sectionClient.setLayout(layout); >- FormToolkit toolkit = getToolkit(); >- >- _properties = new StructuredTreeViewer(_sectionClient, toolkit, >- SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER, this); >- >- GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); >- gd.heightHint = 50; >- gd.widthHint = 50; >- _properties.getControl().setLayoutData(gd); >- _properties.getControl().setData(FormToolkit.KEY_DRAW_BORDER, >- FormToolkit.TREE_BORDER); >- >- // Set up a label provider that knows about the capability (so can >- // extract SemanticDecorations from it) >- _provider = new ResourcePropertiesContentProvider(); >- _properties.setContentProvider(_provider); >- _properties.setLabelProvider(new ResourcePropertiesLabelProvider( >- getForm().getShell())); >- _properties.getControl().setSize(_properties.getControl().computeSize(SWT.DEFAULT, SWT.DEFAULT)); >- >- _buttonClient = toolkit.createComposite(_sectionClient); >- layout = new GridLayout(); >- layout.marginHeight = 0; >- _buttonClient.setLayout(layout); >- gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_FILL, false, false); >- _buttonClient.setLayoutData(gd); >+ private Button _removePropertyButton; > >- _addPropertyButton = createPushButton(_buttonClient, toolkit, org.eclipse.tptp.wsdm.tooling.nls.messages.capability.internal.Messages.ADD_BUTTON_LABEL, >- new Listener() >+ private Label _errorLabel; >+ >+ private Object _selectedObject; >+ >+ private Composite _sectionClient; >+ >+ private Composite _buttonClient; >+ >+ /** >+ * Creates the new object of this class. >+ */ >+ ListSection(CapabilityEditor editor, IUIPage propertyPage, >+ ScrolledForm form, FormToolkit toolkit) >+ { >+ super(editor, propertyPage, form, toolkit); >+ } >+ >+ /** >+ * Creates the section. >+ */ >+ public void create() >+ { >+ _sectionClient = createSection(Messages.PROPERTIES, >+ Messages.PROPS_USED, 1, 4); >+ GridLayout layout = new GridLayout(2, false); >+ layout.marginWidth = LAYOUT_MARGIN_WIDTH; >+ layout.verticalSpacing = LAYOUT_VERTICAL_SPACING; >+ _sectionClient.setLayout(layout); >+ FormToolkit toolkit = getToolkit(); >+ >+ _properties = new StructuredTreeViewer(_sectionClient, toolkit, >+ SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER, this); >+ >+ GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); >+ gd.heightHint = 50; >+ gd.widthHint = 50; >+ _properties.getControl().setLayoutData(gd); >+ _properties.getControl().setData(FormToolkit.KEY_DRAW_BORDER, >+ FormToolkit.TREE_BORDER); >+ >+ // Set up a label provider that knows about the capability (so can >+ // extract SemanticDecorations from it) >+ _provider = new ResourcePropertiesContentProvider(); >+ _properties.setContentProvider(_provider); >+ _properties.setLabelProvider(new ResourcePropertiesLabelProvider( >+ getForm().getShell())); >+ _properties.getControl().setSize( >+ _properties.getControl().computeSize(SWT.DEFAULT, SWT.DEFAULT)); >+ >+ _buttonClient = toolkit.createComposite(_sectionClient); >+ layout = new GridLayout(); >+ layout.marginHeight = 0; >+ _buttonClient.setLayout(layout); >+ gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, >+ GridData.VERTICAL_ALIGN_FILL, false, false); >+ _buttonClient.setLayoutData(gd); >+ >+ _addPropertyButton = createPushButton( >+ _buttonClient, >+ toolkit, >+ org.eclipse.tptp.wsdm.tooling.nls.messages.capability.internal.Messages.ADD_BUTTON_LABEL, >+ new Listener() { >+ public void handleEvent(Event event) >+ { >+ addProperty(); >+ } >+ }); >+ gd = new GridData(GridData.CENTER, SWT.NONE, false, false); >+ gd.widthHint = 80; >+ _addPropertyButton.setLayoutData(gd); >+ _addPropertyButton.setEnabled(!_editor.isReadOnly()); >+ >+ _editMetadataButton = createPushButton(_buttonClient, toolkit, >+ Messages.EDIT_METADATA_LABEL, new Listener() { >+ public void handleEvent(Event event) >+ { >+ editMetadata(); >+ } >+ }); >+ gd = new GridData(GridData.CENTER, SWT.NONE, false, false); >+ gd.widthHint = 80; >+ _editMetadataButton.setLayoutData(gd); >+ _editMetadataButton.setEnabled(false); >+ >+ _removePropertyButton = createPushButton( >+ _buttonClient, >+ toolkit, >+ org.eclipse.tptp.wsdm.tooling.nls.messages.capability.internal.Messages.REMOVE_BUTTON_LABEL, >+ new Listener() { >+ public void handleEvent(Event event) >+ { >+ removeProperty(); >+ } >+ }); >+ gd = new GridData(GridData.CENTER, SWT.NONE, false, false); >+ gd.widthHint = 80; >+ _removePropertyButton.setLayoutData(gd); >+ _removePropertyButton.setEnabled(false); >+ >+ _errorLabel = toolkit.createLabel(_sectionClient, "", SWT.WRAP); >+ gd = new GridData(); >+ gd.horizontalSpan = 2; >+ gd.grabExcessHorizontalSpace = true; >+ gd.horizontalAlignment = SWT.FILL; >+ _errorLabel.setLayoutData(gd); >+ } >+ >+ private void addProperty() >+ { >+ CapabilityDomain capabilityDomain = _editor.getCapabilityDomain(); >+ NewPropertyDialog dlg = new NewPropertyDialog(getForm().getShell(), >+ Messages.ADD_PROPERTY, capabilityDomain); >+ int choice = dlg.open(); >+ if (choice == Window.OK) > { >- public void handleEvent(Event event) >- { >- addProperty(); >- } >- }); >- gd = new GridData(GridData.CENTER, SWT.NONE, false, false); >- gd.widthHint = 80; >- _addPropertyButton.setLayoutData(gd); >- _addPropertyButton.setEnabled(!_editor.isReadOnly()); >+ XSDElementDeclaration propertyElement = dlg.getProperty(); >+ AddPropertyCommand command_1 = new AddPropertyCommand( >+ capabilityDomain, propertyElement); >+ command_1.execute(); >+ Property property = command_1.getProperty(); >+ >+ DataType dataType = dlg.getDataType(); >+ ChangePropertyTypeCommand command_2 = new ChangePropertyTypeCommand( >+ capabilityDomain, property, dataType); >+ command_2.execute(); >+ >+ int minoccurs = dlg.getMinOcuurs(); >+ int maxoccurs = dlg.getMaxOccurs(); >+ ChangePropertyCardinalityCommand command_3 = new ChangePropertyCardinalityCommand( >+ capabilityDomain, property, minoccurs, maxoccurs); >+ command_3.execute(); >+ >+ ChangeModifiabilityCommand command_4 = new ChangeModifiabilityCommand( >+ capabilityDomain, property, dlg.getModifiability()); >+ command_4.execute(); >+ >+ ChangeMutabilityCommand command_5 = new ChangeMutabilityCommand( >+ capabilityDomain, property, dlg.getMutability()); >+ command_5.execute(); >+ >+ _selectedObject = property; >+ _page.setDirty(); >+ } >+ } > >- _editMetadataButton = createPushButton(_buttonClient, toolkit, >- Messages.EDIT_METADATA_LABEL, new Listener() >+ private void editMetadata() >+ { >+ CapabilityDomain capabilityDomain = (CapabilityDomain) _editor >+ .getCapabilityDomain(); >+ Property property = (Property) _selectedObject; >+ MetadataPropertyDialog dlg = new MetadataPropertyDialog(getForm() >+ .getShell(), capabilityDomain, property); >+ int choice = dlg.open(); >+ if (choice == Window.OK) > { >- public void handleEvent(Event event) >- { >- editMetadata(); >- } >- }); >- gd = new GridData(GridData.CENTER, SWT.NONE, false, false); >- gd.widthHint = 80; >- _editMetadataButton.setLayoutData(gd); >- _editMetadataButton.setEnabled(false); >+ _page.setDirty(); >+ } >+ } > >- _removePropertyButton = createPushButton(_buttonClient, toolkit, >- org.eclipse.tptp.wsdm.tooling.nls.messages.capability.internal.Messages.REMOVE_BUTTON_LABEL, new Listener() >+ private void removeProperty() >+ { >+ Property property = (Property) _selectedObject; >+ CapabilityDomain capabilityDomain = _editor.getCapabilityDomain(); >+ RemovePropertyCommand command = new RemovePropertyCommand( >+ capabilityDomain, property); >+ command.execute(); >+ _selectedObject = null; >+ _page.setDirty(); >+ } >+ >+ /** >+ * Handle double click. >+ */ >+ public void handleDoubleClick() >+ { >+ } >+ >+ /** >+ * Handle selection changed. >+ */ >+ public void handleSelectionChanged(SelectionChangedEvent event) >+ { >+ Object[] objects = _properties.getSelectedObjets(); >+ _removePropertyButton.setEnabled(objects.length > 0 >+ && !_editor.isReadOnly()); >+ _editMetadataButton.setEnabled(objects.length > 0 >+ && !_editor.isReadOnly()); >+ if (objects.length > 0) > { >- public void handleEvent(Event event) >- { >- removeProperty(); >- } >- }); >- gd = new GridData(GridData.CENTER, SWT.NONE, false, false); >- gd.widthHint = 80; >- _removePropertyButton.setLayoutData(gd); >- _removePropertyButton.setEnabled(false); >- >- _errorLabel = toolkit.createLabel(_sectionClient, "", SWT.WRAP ); >- gd = new GridData(); >- gd.horizontalSpan = 2; >- gd.grabExcessHorizontalSpace = true; >- gd.horizontalAlignment = SWT.FILL; >- _errorLabel.setLayoutData(gd); >- } >- >- private void addProperty() >- { >- CapabilityDomain capabilityDomain = _editor.getCapabilityDomain(); >- NewPropertyDialog dlg = new NewPropertyDialog(getForm().getShell(), >- Messages.ADD_PROPERTY, capabilityDomain); >- int choice = dlg.open(); >- if (choice == Window.OK) >- { >- XSDElementDeclaration propertyElement = dlg.getProperty(); >- AddPropertyCommand command_1 = new AddPropertyCommand( >- capabilityDomain, propertyElement); >- command_1.execute(); >- Property property = command_1.getProperty(); >- >- DataType dataType = dlg.getDataType(); >- ChangePropertyTypeCommand command_2 = new ChangePropertyTypeCommand(capabilityDomain, property, dataType); >- command_2.execute(); >- >- int minoccurs = dlg.getMinOcuurs(); >- int maxoccurs = dlg.getMaxOccurs(); >- ChangePropertyCardinalityCommand command_3 = new ChangePropertyCardinalityCommand( >- capabilityDomain, property, minoccurs, maxoccurs); >- command_3.execute(); >- >- ChangeModifiabilityCommand command_4 = new ChangeModifiabilityCommand( >- capabilityDomain, property, dlg.getModifiability()); >- command_4.execute(); >- >- ChangeMutabilityCommand command_5 = new ChangeMutabilityCommand( >- capabilityDomain, property, dlg.getMutability()); >- command_5.execute(); >- >- _selectedObject = property; >- _page.setDirty(); >- } >- } >- >- private void editMetadata() >- { >- CapabilityDomain capabilityDomain = (CapabilityDomain) _editor >- .getCapabilityDomain(); >- Property property = (Property) _selectedObject; >- MetadataPropertyDialog dlg = new MetadataPropertyDialog(getForm() >- .getShell(), capabilityDomain, property); >- int choice = dlg.open(); >- if (choice == Window.OK) >- { >- _page.setDirty(); >- } >- } >- >- private void removeProperty() >- { >- Property property = (Property) _selectedObject; >- CapabilityDomain capabilityDomain = _editor.getCapabilityDomain(); >- RemovePropertyCommand command = new RemovePropertyCommand( >- capabilityDomain, property); >- command.execute(); >- _selectedObject = null; >- _page.setDirty(); >- } >- >- /** >- * Handle double click. >- */ >- public void handleDoubleClick() >- { >- } >- >- /** >- * Handle selection changed. >- */ >- public void handleSelectionChanged(SelectionChangedEvent event) >- { >- Object[] objects = _properties.getSelectedObjets(); >- _removePropertyButton.setEnabled(objects.length > 0 && !_editor.isReadOnly()); >- _editMetadataButton.setEnabled(objects.length > 0 && !_editor.isReadOnly()); >- if (objects.length > 0) >- { >- _selectedObject = objects[0]; >- _editMetadataButton.setEnabled(_selectedObject instanceof Property && !_editor.isReadOnly()); >- _removePropertyButton.setEnabled(_selectedObject instanceof Property && !_editor.isReadOnly()); >- List sections = _page.getSections(); >- for (int i = 0; i < sections.size(); i++) >- { >- IPageSection section = (IPageSection) sections.get(i); >- section.setSelectedObject(_selectedObject); >- section.selectionChanged(event); >- } >- } >- } >- >- /** >- * Refreshes the section. >- */ >- public void refresh() >- { >- List propertiesList = _editor.getCapabilityDomain().getCapability() >- .getProperties(); >- _properties.setInput(propertiesList); >- if (propertiesList.size() != 0 && _selectedObject != null) >- { >- _page.enableSections(true); >- setFocusToProperty(_selectedObject); >- } >- else >- { >- _page.enableSections(false); >- } >- updateErrorMessage(); >- } >- >- private void updateErrorMessage() >- { >- Definition defintion = _editor.getCapabilityDomain().getDefinition(); >- XSDSchema propSchema = _editor.getCapabilityDomain().getPropertySchema(); >- if(propSchema == null) >- return; >- if(_editor.getCapabilityDomain().getMetaDataDescriptor() == null) >- return; >- DocumentRoot root = _editor.getCapabilityDomain().getMetaDataDescriptor().getDocumentRoot(); >- >- CapabilityXSDValidator xsdValidator = new CapabilityXSDValidator(); >- IValidationReport xsdReport = xsdValidator.validate(defintion,propSchema); >- boolean xsdHasProblem = xsdReport.hasErrors() || xsdReport.hasWarnings(); >- >- CapabilityRMDValidator rmdValidator = new CapabilityRMDValidator(); >- IValidationReport rmdReport = rmdValidator.validate(defintion,root); >- boolean rmdHasProblem = rmdReport.hasErrors() || rmdReport.hasWarnings(); >- >- boolean hasProblem = xsdHasProblem || rmdHasProblem; >- >- if (hasProblem) >- { >- // We have a problem, is it an error or just a warning? >- boolean hasError = false; >- String msg; >- if (xsdReport.hasErrors() || rmdReport.hasErrors()) >- { >- hasError = true; >- if(xsdReport.hasErrors()) >- msg = xsdReport.getErrorMessages()[0].getMessage(); >+ _selectedObject = objects[0]; >+ _editMetadataButton.setEnabled(_selectedObject instanceof Property >+ && !_editor.isReadOnly()); >+ _removePropertyButton >+ .setEnabled(_selectedObject instanceof Property >+ && !_editor.isReadOnly()); >+ List sections = _page.getSections(); >+ for (int i = 0; i < sections.size(); i++) >+ { >+ IPageSection section = (IPageSection) sections.get(i); >+ section.setSelectedObject(_selectedObject); >+ section.selectionChanged(event); >+ } >+ } >+ } >+ >+ /** >+ * Refreshes the section. >+ */ >+ public void refresh() >+ { >+ List propertiesList = _editor.getCapabilityDomain().getCapability() >+ .getProperties(); >+ _properties.setInput(propertiesList); >+ if (propertiesList.size() != 0 && _selectedObject != null) >+ { >+ _page.enableSections(true); >+ setFocusToProperty(_selectedObject); >+ } > else >- msg = rmdReport.getErrorMessages()[0].getMessage(); >- } >- else >- { >- if(xsdReport.hasWarnings()) >- msg = xsdReport.getWarningMessages()[0].getMessage(); >+ { >+ _page.enableSections(false); >+ } >+ updateErrorMessage(); >+ } >+ >+ private void updateErrorMessage() >+ { >+ Definition defintion = _editor.getCapabilityDomain().getCapability() >+ .getDefinition(); >+ XSDSchema propSchema = _editor.getCapabilityDomain() >+ .getPropertySchema(); >+ if (propSchema == null) >+ return; >+ if (_editor.getCapabilityDomain().getCapability().getMetadata() == null) >+ return; >+ DocumentRoot root = _editor.getCapabilityDomain().getCapability() >+ .getMetadata().getDocumentRoot(); >+ >+ CapabilityXSDValidator xsdValidator = new CapabilityXSDValidator(); >+ IValidationReport xsdReport = xsdValidator.validate(defintion, >+ propSchema); >+ boolean xsdHasProblem = xsdReport.hasErrors() >+ || xsdReport.hasWarnings(); >+ >+ CapabilityRMDValidator rmdValidator = new CapabilityRMDValidator(); >+ IValidationReport rmdReport = rmdValidator.validate(defintion, root); >+ boolean rmdHasProblem = rmdReport.hasErrors() >+ || rmdReport.hasWarnings(); >+ >+ boolean hasProblem = xsdHasProblem || rmdHasProblem; >+ >+ if (hasProblem) >+ { >+ // We have a problem, is it an error or just a warning? >+ boolean hasError = false; >+ String msg; >+ if (xsdReport.hasErrors() || rmdReport.hasErrors()) >+ { >+ hasError = true; >+ if (xsdReport.hasErrors()) >+ msg = xsdReport.getErrorMessages()[0].getMessage(); >+ else >+ msg = rmdReport.getErrorMessages()[0].getMessage(); >+ } >+ else >+ { >+ if (xsdReport.hasWarnings()) >+ msg = xsdReport.getWarningMessages()[0].getMessage(); >+ else >+ msg = rmdReport.getWarningMessages()[0].getMessage(); >+ } >+ _errorLabel.setBackground(getForm().getDisplay().getSystemColor( >+ hasError ? SWT.COLOR_RED : SWT.COLOR_YELLOW)); >+ _errorLabel.setForeground(getForm().getDisplay().getSystemColor( >+ hasError ? SWT.COLOR_WHITE : SWT.COLOR_BLACK)); >+ _errorLabel.setText(" " + msg + " "); >+ } > else >- msg = rmdReport.getWarningMessages()[0].getMessage(); >- } >- _errorLabel.setBackground(getForm().getDisplay().getSystemColor( >- hasError ? SWT.COLOR_RED : SWT.COLOR_YELLOW)); >- _errorLabel.setForeground(getForm().getDisplay().getSystemColor( >- hasError ? SWT.COLOR_WHITE : SWT.COLOR_BLACK)); >- _errorLabel.setText(" " + msg + " "); >- } >- else >- { >- _errorLabel.setBackground(getForm().getBackground()); >- _errorLabel.setForeground(getForm().getForeground()); >- _errorLabel.setText(""); >- } >- } >- >- /** >- * Update its selected object. >- */ >- public void setSelectedObject(Object object) >- { >- _selectedObject = object; >- } >- >- /** >- * Handle viewer selection changed. >- */ >- public void selectionChanged(SelectionChangedEvent event) >- { >- } >- >- /** >- * Initializes control listeners. >- */ >- public void hookAllListeners() >- { >- getForm().addControlListener(new ControlAdapter() { >- public void controlResized(ControlEvent e) { >- Rectangle formBounds = getForm().getClientArea(); >- Rectangle sectionClientBounds = _sectionClient.getClientArea(); >- Rectangle buttonCompositeBounds = _buttonClient.getClientArea(); >- int width = sectionClientBounds.width-buttonCompositeBounds.width-20; >- int height = Math.min(formBounds.height, sectionClientBounds.height)-100; >- Tree tree = (Tree) _properties.getControl(); >- tree.setSize(width,height); >- } >- }); >- } >- >- /** >- * Enable or disable the section based on parameter passed. >- */ >- public void enable(boolean enabled) >- { >- // TODO Auto-generated method stub >- } >- >- private void setFocusToProperty(Object property) >- { >- _selectedObject = property; >- _properties.setSelection(new StructuredSelection(property), false); >- } >+ { >+ _errorLabel.setBackground(getForm().getBackground()); >+ _errorLabel.setForeground(getForm().getForeground()); >+ _errorLabel.setText(""); >+ } >+ } >+ >+ /** >+ * Update its selected object. >+ */ >+ public void setSelectedObject(Object object) >+ { >+ _selectedObject = object; >+ } >+ >+ /** >+ * Handle viewer selection changed. >+ */ >+ public void selectionChanged(SelectionChangedEvent event) >+ { >+ } >+ >+ /** >+ * Initializes control listeners. >+ */ >+ public void hookAllListeners() >+ { >+ getForm().addControlListener(new ControlAdapter() { >+ public void controlResized(ControlEvent e) >+ { >+ Rectangle formBounds = getForm().getClientArea(); >+ Rectangle sectionClientBounds = _sectionClient.getClientArea(); >+ Rectangle buttonCompositeBounds = _buttonClient.getClientArea(); >+ int width = sectionClientBounds.width >+ - buttonCompositeBounds.width - 20; >+ int height = Math.min(formBounds.height, >+ sectionClientBounds.height) - 100; >+ Tree tree = (Tree) _properties.getControl(); >+ tree.setSize(width, height); >+ } >+ }); >+ } >+ >+ /** >+ * Enable or disable the section based on parameter passed. >+ */ >+ public void enable(boolean enabled) >+ { >+ // TODO Auto-generated method stub >+ } >+ >+ private void setFocusToProperty(Object property) >+ { >+ _selectedObject = property; >+ _properties.setSelection(new StructuredSelection(property), false); >+ } > > } >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/property/internal/MetadataPropertyDialog.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.editor.capability/src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/property/internal/MetadataPropertyDialog.java,v >retrieving revision 1.6 >diff -u -r1.6 MetadataPropertyDialog.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/property/internal/MetadataPropertyDialog.java 9 Jan 2007 19:51:43 -0000 1.6 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/property/internal/MetadataPropertyDialog.java 20 Jan 2007 13:33:39 -0000 >@@ -23,7 +23,6 @@ > import org.eclipse.emf.ecore.util.FeatureMapUtil; > import org.eclipse.emf.ecore.xml.type.AnyType; > import org.eclipse.emf.ecore.xml.type.XMLTypeFactory; >-import org.eclipse.emf.ecore.xml.type.internal.QName; > import org.eclipse.jface.dialogs.Dialog; > import org.eclipse.jface.dialogs.IDialogConstants; > import org.eclipse.jface.dialogs.IInputValidator; >@@ -46,6 +45,7 @@ > import org.eclipse.tptp.wsdm.tooling.editor.capability.internal.CapabilityDomain; > import org.eclipse.tptp.wsdm.tooling.editor.capability.util.internal.MetaDataUtils; > import org.eclipse.tptp.wsdm.tooling.model.capabilities.Property; >+import org.eclipse.tptp.wsdm.tooling.model.capabilities.impl.MetadataDescriptor; > import org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.MetadataDescriptorFactory; > import org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.PropertyType; > import org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.StaticValuesType; >@@ -53,740 +53,745 @@ > import org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.ValidValuesType; > import org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.impl.MetadataDescriptorFactoryImpl; > import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.property.internal.Messages; >-import org.eclipse.tptp.wsdm.tooling.util.internal.PropertyMetaDataDescriptor; > import org.eclipse.tptp.wsdm.tooling.util.internal.Validation; > import org.eclipse.tptp.wsdm.tooling.util.internal.XsdUtils; > > /** > * >- * Popup dialog to define metadata ( such as enumarated values, default values, ranged values ) >- * for a property. >- * >+ * Popup dialog to define metadata ( such as enumarated values, default values, >+ * ranged values ) for a property. >+ * > */ > > public class MetadataPropertyDialog extends Dialog > { > >- private List _listDefault; >- >- private Group _extraSchema; >+ private List _listDefault; > >- private Button _propUnlimited; >+ private Group _extraSchema; > >- private Button _propValidValues; >+ private Button _propUnlimited; > >- private List _listValidEnum; >+ private Button _propValidValues; > >- private Button _propValidRange; >+ private List _listValidEnum; >+ >+ private Button _propValidRange; >+ >+ private Label _labelMin; >+ >+ private Label _labelMax; >+ >+ private Text _fieldMin; >+ >+ private Text _fieldMax; >+ >+ private Button _buttonAddEnum; >+ >+ private Button _buttonEditEnum; >+ >+ private Button _buttonDelEnum; >+ >+ private Button _buttonAddDefault; >+ >+ private Button _buttonDelDefault; >+ >+ private Button _buttonEditDefault; >+ >+ private Property _property; >+ >+ private MetadataDescriptorFactory _rmdFactory = new MetadataDescriptorFactoryImpl(); >+ >+ private ExtendedMetaData _extendedMetaData; >+ >+ private CapabilityDomain _capabilityDomain; >+ >+ /** >+ * Creates a dialog for providing intial values and static vlaues for >+ * property.<br> >+ * >+ * @param parentShell >+ * Shell. >+ * >+ * @param capabilityDomain >+ * Capability domain of capability editor. >+ * >+ * @param property >+ * Property selected for metadata editing. >+ */ >+ protected MetadataPropertyDialog(Shell parentShell, >+ CapabilityDomain capabilityDomain, Property property) >+ { >+ super(parentShell); >+ _property = property; >+ _extendedMetaData = createExtendedMetaData(); >+ _capabilityDomain = capabilityDomain; >+ } >+ >+ private ExtendedMetaData createExtendedMetaData() >+ { >+ ResourceSet resourceSet = new ResourceSetImpl(); >+ ExtendedMetaData extendedMetaData = new BasicExtendedMetaData( >+ resourceSet.getPackageRegistry()); >+ return extendedMetaData; >+ } >+ >+ /** >+ * Configure the shell. >+ */ >+ protected void configureShell(Shell shell) >+ { >+ super.configureShell(shell); >+ String propName = XsdUtils.getName(_property.getElement()); >+ shell.setText(NLS.bind(Messages.EDIT_PROPERTY_DEFINITION, propName)); >+ } >+ >+ /** >+ * Creates the dialog area. >+ */ >+ protected Control createDialogArea(Composite parent) >+ { >+ Composite composite = (Composite) super.createDialogArea(parent); >+ >+ GridLayout layout = new GridLayout(2, false); >+ composite.setLayout(layout); >+ >+ createValidValuesGroup(composite); >+ createDefaultValuesGroup(composite); >+ >+ applyDialogFont(composite); >+ return composite; >+ } >+ >+ private void createValidValuesGroup(Composite parent) >+ { >+ _extraSchema = new Group(parent, SWT.LEFT | SWT.BOTTOM); >+ _extraSchema.setText(Messages.PROP_VALUE_RESTRICTION); >+ >+ GridLayout layout = new GridLayout(2, false); >+ _extraSchema.setLayout(layout); >+ >+ GridData gd = new GridData(GridData.FILL_VERTICAL); >+ _extraSchema.setLayoutData(gd); >+ >+ _propUnlimited = new Button(_extraSchema, SWT.RADIO); >+ _propUnlimited.setText(Messages.UNRESTRICTED_LABEL); >+ setSpan(_propUnlimited, 2); >+ _propUnlimited.addListener(SWT.Selection, new Listener() { >+ public void handleEvent(Event event) >+ { >+ enableDisableOnValidationType(); >+ } >+ }); >+ >+ _propValidValues = new Button(_extraSchema, SWT.RADIO); >+ _propValidValues.setText(Messages.ENUMARATED_LABEL); >+ setSpan(_propValidValues, 2); >+ _propValidValues.addListener(SWT.Selection, new Listener() { >+ public void handleEvent(Event event) >+ { >+ enableDisableOnValidationType(); >+ } >+ }); >+ >+ createAddRemoveEnumButtons(_extraSchema); >+ >+ _propValidRange = new Button(_extraSchema, SWT.RADIO); >+ _propValidRange.setText(Messages.RANGED_LABEL); >+ setSpan(_propValidRange, 2); >+ _propValidRange.addListener(SWT.Selection, new Listener() { >+ public void handleEvent(Event event) >+ { >+ enableDisableOnValidationType(); >+ } >+ }); >+ >+ _labelMin = new Label(_extraSchema, SWT.NONE); >+ _labelMin.setText(Messages.MIN_LABLE); >+ _labelMax = new Label(_extraSchema, SWT.NONE); >+ _labelMax.setText(Messages.MAX_LABEL); >+ _fieldMin = new Text(_extraSchema, SWT.LEFT | SWT.BORDER); >+ gd = new GridData(GridData.FILL); >+ gd.widthHint = 60; >+ _fieldMin.setLayoutData(gd); >+ _fieldMax = new Text(_extraSchema, SWT.LEFT | SWT.BORDER); >+ gd = new GridData(GridData.FILL); >+ gd.widthHint = 60; >+ _fieldMax.setLayoutData(gd); >+ } >+ >+ private void createDefaultValuesGroup(Composite parent) >+ { >+ Group composite = new Group(parent, SWT.LEFT | SWT.BOTTOM); >+ composite.setText(Messages.DEFAULT_PROP_VALUES_LABEL); >+ >+ GridLayout layout = new GridLayout(3, false); >+ composite.setLayout(layout); >+ >+ GridData gdMain = new GridData(); >+ gdMain.verticalAlignment = GridData.FILL; >+ composite.setLayoutData(gdMain); >+ >+ _listDefault = new List(composite, SWT.MULTI | SWT.BORDER >+ | SWT.H_SCROLL | SWT.V_SCROLL); >+ GridData gd = new GridData(); >+ gd.heightHint = 146; >+ gd.widthHint = 200; >+ gd.horizontalSpan = 3; >+ _listDefault.setLayoutData(gd); >+ >+ _listDefault.addListener(SWT.Selection, new Listener() { >+ >+ public void handleEvent(Event event) >+ { >+ selectedDefault(); >+ } >+ }); >+ >+ _buttonAddDefault = new Button(composite, SWT.PUSH); >+ _buttonAddDefault.setText(Messages.ADD_DEFAULT_LABEL); >+ _buttonAddDefault.addListener(SWT.Selection, new Listener() { >+ public void handleEvent(Event event) >+ { >+ addNewDefault(); >+ } >+ }); >+ >+ _buttonEditDefault = new Button(composite, SWT.PUSH); >+ _buttonEditDefault.setText(Messages.EDIT_DEFAULT_LABEL); >+ _buttonEditDefault.addListener(SWT.Selection, new Listener() { >+ public void handleEvent(Event event) >+ { >+ editDefault(); >+ } >+ }); >+ >+ _buttonDelDefault = new Button(composite, SWT.PUSH); >+ _buttonDelDefault.setText(Messages.REMOVE_DEFAULT_LABEL); >+ _buttonDelDefault.addListener(SWT.Selection, new Listener() { >+ public void handleEvent(Event event) >+ { >+ delDefault(); >+ } >+ }); >+ } >+ >+ /** >+ * <pre> >+ * [Add] [Remove] >+ * </pre> >+ */ >+ private void createAddRemoveEnumButtons(Composite parent) >+ { >+ Composite panelAddDel = new Composite(parent, SWT.NONE); >+ setSpan(panelAddDel, 2); >+ GridLayout layout = new GridLayout(3, false); >+ panelAddDel.setLayout(layout); >+ >+ _listValidEnum = new List(panelAddDel, SWT.MULTI | SWT.BORDER >+ | SWT.H_SCROLL | SWT.V_SCROLL); >+ GridData gdEnum = new GridData(); >+ gdEnum.heightHint = 100; >+ gdEnum.widthHint = 200; >+ gdEnum.horizontalSpan = 3; >+ _listValidEnum.setLayoutData(gdEnum); >+ >+ _listValidEnum.addListener(SWT.Selection, new Listener() { >+ public void handleEvent(Event event) >+ { >+ selectedEnumeration(); >+ } >+ }); >+ >+ _buttonAddEnum = new Button(panelAddDel, SWT.PUSH); >+ _buttonAddEnum.setText(Messages.ADD_ENUM_LABEL); >+ _buttonAddEnum.addListener(SWT.Selection, new Listener() { >+ public void handleEvent(Event event) >+ { >+ addNewValidValueEnum(); >+ } >+ }); >+ >+ _buttonEditEnum = new Button(panelAddDel, SWT.PUSH); >+ _buttonEditEnum.setText(Messages.EDIT_ENUM_LABEL); >+ _buttonEditEnum.addListener(SWT.Selection, new Listener() { >+ public void handleEvent(Event event) >+ { >+ editValidValueEnum(); >+ } >+ }); >+ >+ _buttonDelEnum = new Button(panelAddDel, SWT.PUSH); >+ _buttonDelEnum.setText(Messages.REMOVE_ENUM_LABEL); >+ _buttonDelEnum.addListener(SWT.Selection, new Listener() { >+ public void handleEvent(Event event) >+ { >+ delValidValueEnum(); >+ } >+ }); > >- private Label _labelMin; >+ selectedEnumeration(); >+ } > >- private Label _labelMax; >+ /** >+ * User clicked hoping for new enum value creation function >+ */ >+ protected void addNewValidValueEnum() >+ { >+ IInputValidator validator = new IInputValidator() { >+ public String isValid(String newText) >+ { >+ /* >+ * if (!Validation.isNCName(newText)) return ""; >+ */ >+ if (newText.equals("")) >+ return ""; >+ if (_listValidEnum.indexOf(newText) != -1) >+ return Messages.DUPLICATE_VALUE_LABEL; >+ if (!isValidUserInputAgainstPropertyType(newText)) >+ return Messages.INVALID_RESTRICTED_VALUE_FOR_PROPERTY; >+ return null; >+ } >+ }; >+ >+ InputDialog dlg = new InputDialog(getShell(), >+ Messages.VALID_VALUE_ENUM_LABEL, Messages.NEW_ENUM_VALUE_LABEL, >+ "", validator); > >- private Text _fieldMin; >+ int choice = dlg.open(); >+ if (choice == Window.OK) >+ { >+ String newEnum = dlg.getValue().trim(); >+ _listValidEnum.add(newEnum); >+ } >+ } > >- private Text _fieldMax; >+ protected void editValidValueEnum() >+ { >+ IInputValidator validator = new IInputValidator() { >+ public String isValid(String newText) >+ { >+ /* >+ * if (!Validation.isNCName(newText)) return ""; >+ */ >+ if (newText.equals("")) >+ return ""; >+ if (_listValidEnum.indexOf(newText) != -1) >+ return Messages.DUPLICATE_VALUE_LABEL; >+ if (!isValidUserInputAgainstPropertyType(newText)) >+ return Messages.INVALID_RESTRICTED_VALUE_FOR_PROPERTY; >+ return null; >+ } >+ }; >+ >+ InputDialog dlg = new InputDialog(getShell(), >+ Messages.VALID_VALUE_ENUM_LABEL, >+ Messages.EDIT_ENUM_VALUE_LABEL, >+ _listValidEnum.getSelection()[0], validator); > >- private Button _buttonAddEnum; >+ int choice = dlg.open(); >+ if (choice == Window.OK) >+ { >+ String newEnum = dlg.getValue().trim(); >+ _listValidEnum.remove(_listValidEnum.getSelectionIndices()); >+ _listValidEnum.add(newEnum); >+ selectedEnumeration(); >+ } >+ } > >- private Button _buttonEditEnum; >+ /** >+ * User clicked hoping to remove enum(s) >+ */ >+ protected void delValidValueEnum() >+ { >+ // Remove from GUI >+ _listValidEnum.remove(_listValidEnum.getSelectionIndices()); >+ selectedEnumeration(); >+ } > >- private Button _buttonDelEnum; >+ private void addDefault(String newDef) >+ { >+ newDef = newDef.trim(); > >- private Button _buttonAddDefault; >+ // changedDefaults = true; >+ selectedDefault(); > >- private Button _buttonDelDefault; >+ // If the restriction is 'enumerated', ensure the added default is legal >+ // by adding it to the enumeration if it isn't already there >+ if (_propValidValues.getSelection()) >+ { >+ if (!Arrays.asList(_listValidEnum.getItems()).contains(newDef)) >+ { >+ _listValidEnum.add(newDef); >+ } >+ } >+ } > >- private Button _buttonEditDefault; >+ protected void addNewDefault() >+ { >+ IInputValidator validator = new IInputValidator() { >+ public String isValid(String newText) >+ { >+ /* >+ * if (!Validation.isNCName(newText)) return ""; >+ */ >+ if (newText.equals("")) >+ return ""; >+ if (_listDefault.indexOf(newText) != -1) >+ return Messages.DUPLICATE_VALUE_LABEL; >+ if (!isValidUserInputAgainstPropertyType(newText)) >+ return Messages.INVALID_RESTRICTED_VALUE_FOR_PROPERTY; >+ return null; >+ } >+ }; >+ >+ InputDialog dlg = new InputDialog(getShell(), >+ Messages.DEFAULT_VALUE_LABEL, Messages.NEW_DEFAULT_VALUE_LABEL, >+ "", validator); > >- private Property _property; >+ int choice = dlg.open(); >+ if (choice == Window.OK) >+ { >+ String newDef = dlg.getValue(); >+ _listDefault.add(newDef.trim()); >+ addDefault(newDef); >+ } >+ } > >- private MetadataDescriptorFactory _rmdFactory = new MetadataDescriptorFactoryImpl(); >+ protected void editDefault() >+ { >+ IInputValidator validator = new IInputValidator() { >+ public String isValid(String newText) >+ { >+ /* >+ * if (newText.equals("")) return ""; >+ */ >+ if (newText.equals("")) >+ return ""; >+ if (_listDefault.indexOf(newText) != -1) >+ return Messages.DUPLICATE_VALUE_LABEL; >+ if (!isValidUserInputAgainstPropertyType(newText)) >+ return Messages.INVALID_RESTRICTED_VALUE_FOR_PROPERTY; >+ return null; >+ } >+ }; >+ >+ InputDialog dlg = new InputDialog(getShell(), >+ Messages.DEFAULT_VALUE_LABEL, >+ Messages.EDIT_DEFAULT_VALUE_LABEL, >+ _listDefault.getSelection()[0], validator); > >- private ExtendedMetaData _extendedMetaData; >+ int choice = dlg.open(); >+ if (choice == Window.OK) >+ { >+ String newDef = dlg.getValue().trim(); > >- private CapabilityDomain _capabilityDomain; >+ if (newDef.equals("")) >+ return; // Do not allow empty value > >- /** >- * Creates a dialog for providing intial values and static vlaues for property.<br> >- * >- * @param parentShell >- * Shell. >- * >- * @param capabilityDomain >- * Capability domain of capability editor. >- * >- * @param property >- * Property selected for metadata editing. >- */ >- protected MetadataPropertyDialog(Shell parentShell, >- CapabilityDomain capabilityDomain, Property property) >- { >- super(parentShell); >- _property = property; >- _extendedMetaData = createExtendedMetaData(); >- _capabilityDomain = capabilityDomain; >- } >+ if (_listDefault.indexOf(newDef) == -1) >+ { // Do not duplicate >+ int[] indices = _listDefault.getSelectionIndices(); >+ _listDefault.remove(indices); >+ _listDefault.add(newDef, indices[0]); >+ } >+ >+ // If the restriction is 'enumerated', ensure the added default >+ // is legal >+ // by adding it to the enumeration if it isn't already there >+ if (_propValidValues.getSelection()) >+ { >+ if (!Arrays.asList(_listValidEnum.getItems()).contains(newDef)) >+ { >+ _listValidEnum.add(newDef); >+ } >+ // TODO Remove the old, pre-edit from the enumeration? >+ } >+ } >+ } > >- private ExtendedMetaData createExtendedMetaData() >- { >- ResourceSet resourceSet = new ResourceSetImpl(); >- ExtendedMetaData extendedMetaData = new BasicExtendedMetaData( >- resourceSet.getPackageRegistry()); >- return extendedMetaData; >- } >+ protected void delDefault() >+ { >+ int[] indices = _listDefault.getSelectionIndices(); >+ _listDefault.remove(indices); >+ selectedDefault(); >+ } > >- /** >- * Configure the shell. >- */ >- protected void configureShell(Shell shell) >- { >- super.configureShell(shell); >- String propName = XsdUtils.getName(_property.getElement()); >- shell.setText(NLS.bind(Messages.EDIT_PROPERTY_DEFINITION,propName)); >- } >+ /** >+ * >+ */ >+ protected void selectedDefault() >+ { >+ _buttonDelDefault.setEnabled(_listDefault.getSelectionCount() > 0); >+ _buttonEditDefault.setEnabled(_listDefault.getSelectionCount() > 0); >+ } > >- /** >- * Creates the dialog area. >- */ >- protected Control createDialogArea(Composite parent) >- { >- Composite composite = (Composite) super.createDialogArea(parent); >+ protected void selectedEnumeration() >+ { >+ _buttonAddEnum.setEnabled(_propValidValues.getSelection()); >+ _buttonDelEnum.setEnabled(_listValidEnum.getSelectionCount() > 0); >+ _buttonEditEnum.setEnabled(_listValidEnum.getSelectionCount() > 0); >+ } > >- GridLayout layout = new GridLayout(2, false); >- composite.setLayout(layout); >+ protected void selectedRange() >+ { >+ _fieldMin.setEnabled(_propValidRange.getSelection()); >+ _fieldMax.setEnabled(_propValidRange.getSelection()); >+ } > >- createValidValuesGroup(composite); >- createDefaultValuesGroup(composite); >+ protected void createButtonsForButtonBar(Composite parent) >+ { >+ // Because we call Dialog.createButton(), rather than Button's >+ // constructor, >+ // we get Dialog's handling of buttons (which is to call >+ // buttonPressed()). >+ createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, >+ true); >+ createButton(parent, IDialogConstants.CANCEL_ID, >+ IDialogConstants.CANCEL_LABEL, false); >+ initializeWidgets(); >+ } > >- applyDialogFont(composite); >- return composite; >- } >+ private void initializeWidgets() >+ { >+ PropertyType metadata = _property.getMetaData(); >+ if (metadata == null) >+ { >+ _propUnlimited.setSelection(true); >+ selectedDefault(); >+ enableDisableOnValidationType(); >+ return; >+ } > >- private void createValidValuesGroup(Composite parent) >- { >- _extraSchema = new Group(parent, SWT.LEFT | SWT.BOTTOM); >- _extraSchema.setText(Messages.PROP_VALUE_RESTRICTION); >+ Object[] validValues = MetaDataUtils.getValidValues(metadata >+ .getValidValues()); >+ if (validValues.length != 0) >+ { >+ for (int i = 0; i < validValues.length; i++) >+ _listValidEnum.add((String) validValues[i]); >+ _propValidValues.setSelection(true); >+ selectedEnumeration(); >+ } > >- GridLayout layout = new GridLayout(2, false); >- _extraSchema.setLayout(layout); >+ if (metadata.getValidValueRange() != null) >+ { >+ _fieldMin.setText((String) metadata.getValidValueRange() >+ .getLowerBound()); >+ _fieldMax.setText((String) metadata.getValidValueRange() >+ .getUpperBound()); >+ _propValidRange.setSelection(true); >+ selectedRange(); >+ } > >- GridData gd = new GridData(GridData.FILL_VERTICAL); >- _extraSchema.setLayoutData(gd); >+ Object[] defaultValues = MetaDataUtils.getStaticValues(metadata >+ .getStaticValues()); >+ if (defaultValues.length != 0) >+ { >+ for (int i = 0; i < defaultValues.length; i++) >+ _listDefault.add((String) defaultValues[i]); >+ } > >- _propUnlimited = new Button(_extraSchema, SWT.RADIO); >- _propUnlimited.setText(Messages.UNRESTRICTED_LABEL); >- setSpan(_propUnlimited, 2); >- _propUnlimited.addListener(SWT.Selection, new Listener() >- { >- public void handleEvent(Event event) >- { >+ selectedDefault(); > enableDisableOnValidationType(); >- } >- }); >+ } > >- _propValidValues = new Button(_extraSchema, SWT.RADIO); >- _propValidValues.setText(Messages.ENUMARATED_LABEL); >- setSpan(_propValidValues, 2); >- _propValidValues.addListener(SWT.Selection, new Listener() >+ protected void okPressed() > { >- public void handleEvent(Event event) >- { >- enableDisableOnValidationType(); >- } >- }); >+ MetadataDescriptor propertyMetaDataDescriptor = _capabilityDomain >+ .getCapability().getMetadata(); >+ if (propertyMetaDataDescriptor == null) >+ { >+ propertyMetaDataDescriptor = createMetaDataDescriptor(); >+ _capabilityDomain.getCapability().setMetadata( >+ propertyMetaDataDescriptor); >+ } > >- createAddRemoveEnumButtons(_extraSchema); >+ PropertyType metadata = _property.getMetaData(); >+ if (metadata == null) >+ { >+ metadata = propertyMetaDataDescriptor.createNewPropertyType(); >+ _property.setMetaData(metadata); >+ String ns = _property.getElement().getTargetNamespace(); >+ String name = XsdUtils.getName(_property.getElement()); >+ String prefix = propertyMetaDataDescriptor.getOrCreatePrefix(ns); >+ metadata.setName(prefix + ":" + name); >+ } > >- _propValidRange = new Button(_extraSchema, SWT.RADIO); >- _propValidRange.setText(Messages.RANGED_LABEL); >- setSpan(_propValidRange, 2); >- _propValidRange.addListener(SWT.Selection, new Listener() >- { >- public void handleEvent(Event event) >- { >- enableDisableOnValidationType(); >- } >- }); >+ metadata.setStaticValues(null); >+ metadata.setValidValueRange(null); >+ metadata.setValidValues(null); > >- _labelMin = new Label(_extraSchema, SWT.NONE); >- _labelMin.setText(Messages.MIN_LABLE); >- _labelMax = new Label(_extraSchema, SWT.NONE); >- _labelMax.setText(Messages.MAX_LABEL); >- _fieldMin = new Text(_extraSchema, SWT.LEFT | SWT.BORDER); >- gd = new GridData(GridData.FILL); >- gd.widthHint = 60; >- _fieldMin.setLayoutData(gd); >- _fieldMax = new Text(_extraSchema, SWT.LEFT | SWT.BORDER); >- gd = new GridData(GridData.FILL); >- gd.widthHint = 60; >- _fieldMax.setLayoutData(gd); >- } >- >- private void createDefaultValuesGroup(Composite parent) >- { >- Group composite = new Group(parent, SWT.LEFT | SWT.BOTTOM); >- composite.setText(Messages.DEFAULT_PROP_VALUES_LABEL); >- >- GridLayout layout = new GridLayout(3, false); >- composite.setLayout(layout); >- >- GridData gdMain = new GridData(); >- gdMain.verticalAlignment = GridData.FILL; >- composite.setLayoutData(gdMain); >- >- _listDefault = new List(composite, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL >- | SWT.V_SCROLL); >- GridData gd = new GridData(); >- gd.heightHint = 146; >- gd.widthHint = 200; >- gd.horizontalSpan = 3; >- _listDefault.setLayoutData(gd); >+ if (_propValidValues.getSelection()) >+ { >+ if (_listValidEnum.getItemCount() > 0) >+ { >+ ValidValuesType validValuesType = _rmdFactory >+ .createValidValuesType(); >+ FeatureMap fm = validValuesType.getAny(); >+ for (int i = 0; i < _listValidEnum.getItemCount(); i++) >+ { >+ String value = _listValidEnum.getItem(i); >+ addValue(fm, value); >+ } >+ metadata.setValidValues(validValuesType); >+ } >+ } >+ else if (_propValidRange.getSelection()) >+ { >+ ValidValueRangeType validValueRange = _rmdFactory >+ .createValidValueRangeType(); >+ validValueRange.setLowerBound(_fieldMin.getText()); >+ validValueRange.setUpperBound(_fieldMax.getText()); >+ metadata.setValidValueRange(validValueRange); >+ } > >- _listDefault.addListener(SWT.Selection, new Listener() >- { >+ if (_listDefault.getItemCount() > 0) >+ { >+ StaticValuesType staticValuesType = _rmdFactory >+ .createStaticValuesType(); >+ FeatureMap fm = staticValuesType.getAny(); >+ for (int i = 0; i < _listDefault.getItemCount(); i++) >+ { >+ String value = _listDefault.getItem(i); >+ addValue(fm, value); >+ } >+ metadata.setStaticValues(staticValuesType); >+ } > >- public void handleEvent(Event event) >- { >- selectedDefault(); >- } >- }); >+ super.okPressed(); >+ } >+ >+ private void addValue(FeatureMap fm, String value) >+ { >+ String namespace = _property.getElement().getTargetNamespace(); >+ String name = XsdUtils.getName(_property.getElement()); >+ EStructuralFeature esf = _extendedMetaData.demandFeature(namespace, >+ name, true); >+ AnyType anyType = XMLTypeFactory.eINSTANCE.createAnyType(); >+ FeatureMapUtil.addText(anyType.getAny(), value); >+ fm.add(esf, anyType); >+ } > >- _buttonAddDefault = new Button(composite, SWT.PUSH); >- _buttonAddDefault.setText(Messages.ADD_DEFAULT_LABEL); >- _buttonAddDefault.addListener(SWT.Selection, new Listener() >- { >- public void handleEvent(Event event) >- { >- addNewDefault(); >- } >- }); >- >- _buttonEditDefault = new Button(composite, SWT.PUSH); >- _buttonEditDefault.setText(Messages.EDIT_DEFAULT_LABEL); >- _buttonEditDefault.addListener(SWT.Selection, new Listener() >- { >- public void handleEvent(Event event) >- { >- editDefault(); >- } >- }); >- >- _buttonDelDefault = new Button(composite, SWT.PUSH); >- _buttonDelDefault.setText(Messages.REMOVE_DEFAULT_LABEL); >- _buttonDelDefault.addListener(SWT.Selection, new Listener() >- { >- public void handleEvent(Event event) >- { >- delDefault(); >- } >- }); >- } >- >- /** >- * <pre> >- * [Add] [Remove] >- * </pre> >- */ >- private void createAddRemoveEnumButtons(Composite parent) >- { >- Composite panelAddDel = new Composite(parent, SWT.NONE); >- setSpan(panelAddDel, 2); >- GridLayout layout = new GridLayout(3, false); >- panelAddDel.setLayout(layout); >- >- _listValidEnum = new List(panelAddDel, SWT.MULTI | SWT.BORDER >- | SWT.H_SCROLL | SWT.V_SCROLL); >- GridData gdEnum = new GridData(); >- gdEnum.heightHint = 100; >- gdEnum.widthHint = 200; >- gdEnum.horizontalSpan = 3; >- _listValidEnum.setLayoutData(gdEnum); >+ private void setSpan(Control c, int newSpan) >+ { >+ GridData gd = new GridData(); >+ gd.horizontalSpan = newSpan; >+ c.setLayoutData(gd); >+ } > >- _listValidEnum.addListener(SWT.Selection, new Listener() >+ /** >+ * Turn the extra-schema validation extra controls on/off based on radio >+ * button selection >+ */ >+ private void enableDisableOnValidationType() > { >- public void handleEvent(Event event) >- { >- selectedEnumeration(); >- } >- }); >+ enableEnumControls(_propValidValues.getSelection()); >+ enableRangeControls(_propValidRange.getSelection()); >+ } > >- _buttonAddEnum = new Button(panelAddDel, SWT.PUSH); >- _buttonAddEnum.setText(Messages.ADD_ENUM_LABEL); >- _buttonAddEnum.addListener(SWT.Selection, new Listener() >- { >- public void handleEvent(Event event) >- { >- addNewValidValueEnum(); >- } >- }); >- >- _buttonEditEnum = new Button(panelAddDel, SWT.PUSH); >- _buttonEditEnum.setText(Messages.EDIT_ENUM_LABEL); >- _buttonEditEnum.addListener(SWT.Selection, new Listener() >- { >- public void handleEvent(Event event) >- { >- editValidValueEnum(); >- } >- }); >- >- _buttonDelEnum = new Button(panelAddDel, SWT.PUSH); >- _buttonDelEnum.setText(Messages.REMOVE_ENUM_LABEL); >- _buttonDelEnum.addListener(SWT.Selection, new Listener() >- { >- public void handleEvent(Event event) >- { >- delValidValueEnum(); >- } >- }); >- >- selectedEnumeration(); >- } >- >- /** >- * User clicked hoping for new enum value creation function >- */ >- protected void addNewValidValueEnum() >- { >- IInputValidator validator = new IInputValidator() >- { >- public String isValid(String newText) >- { >- /*if (!Validation.isNCName(newText)) >- return "";*/ >- if(newText.equals("")) >- return ""; >- if (_listValidEnum.indexOf(newText) != -1) >- return Messages.DUPLICATE_VALUE_LABEL; >- if(!isValidUserInputAgainstPropertyType(newText)) >- return Messages.INVALID_RESTRICTED_VALUE_FOR_PROPERTY; >- return null; >- } >- }; >- >- InputDialog dlg = new InputDialog(getShell(), >- Messages.VALID_VALUE_ENUM_LABEL, Messages.NEW_ENUM_VALUE_LABEL, "", validator); >- >- int choice = dlg.open(); >- if (choice == Window.OK) >- { >- String newEnum = dlg.getValue().trim(); >- _listValidEnum.add(newEnum); >- } >- } >- >- protected void editValidValueEnum() >- { >- IInputValidator validator = new IInputValidator() >- { >- public String isValid(String newText) >- { >- /*if (!Validation.isNCName(newText)) >- return "";*/ >- if(newText.equals("")) >- return ""; >- if (_listValidEnum.indexOf(newText) != -1) >- return Messages.DUPLICATE_VALUE_LABEL; >- if(!isValidUserInputAgainstPropertyType(newText)) >- return Messages.INVALID_RESTRICTED_VALUE_FOR_PROPERTY; >- return null; >- } >- }; >- >- InputDialog dlg = new InputDialog(getShell(), >- Messages.VALID_VALUE_ENUM_LABEL, Messages.EDIT_ENUM_VALUE_LABEL, _listValidEnum >- .getSelection()[0], validator); >- >- int choice = dlg.open(); >- if (choice == Window.OK) >- { >- String newEnum = dlg.getValue().trim(); >- _listValidEnum.remove(_listValidEnum.getSelectionIndices()); >- _listValidEnum.add(newEnum); >- selectedEnumeration(); >- } >- } >- >- /** >- * User clicked hoping to remove enum(s) >- */ >- protected void delValidValueEnum() >- { >- // Remove from GUI >- _listValidEnum.remove(_listValidEnum.getSelectionIndices()); >- selectedEnumeration(); >- } >- >- private void addDefault(String newDef) >- { >- newDef = newDef.trim(); >- >- // changedDefaults = true; >- selectedDefault(); >- >- // If the restriction is 'enumerated', ensure the added default is legal >- // by adding it to the enumeration if it isn't already there >- if (_propValidValues.getSelection()) >- { >- if (!Arrays.asList(_listValidEnum.getItems()).contains(newDef)) >- { >- _listValidEnum.add(newDef); >- } >- } >- } >- >- protected void addNewDefault() >- { >- IInputValidator validator = new IInputValidator() >- { >- public String isValid(String newText) >- { >- /*if (!Validation.isNCName(newText)) >- return "";*/ >- if(newText.equals("")) >- return ""; >- if (_listDefault.indexOf(newText) != -1) >- return Messages.DUPLICATE_VALUE_LABEL; >- if(!isValidUserInputAgainstPropertyType(newText)) >- return Messages.INVALID_RESTRICTED_VALUE_FOR_PROPERTY; >- return null; >- } >- }; >- >- InputDialog dlg = new InputDialog(getShell(), Messages.DEFAULT_VALUE_LABEL, >- Messages.NEW_DEFAULT_VALUE_LABEL, "", validator); >- >- int choice = dlg.open(); >- if (choice == Window.OK) >- { >- String newDef = dlg.getValue(); >- _listDefault.add(newDef.trim()); >- addDefault(newDef); >- } >- } >- >- protected void editDefault() >- { >- IInputValidator validator = new IInputValidator() >- { >- public String isValid(String newText) >- { >- /*if (newText.equals("")) >- return "";*/ >- if(newText.equals("")) >- return ""; >- if (_listDefault.indexOf(newText) != -1) >- return Messages.DUPLICATE_VALUE_LABEL; >- if(!isValidUserInputAgainstPropertyType(newText)) >- return Messages.INVALID_RESTRICTED_VALUE_FOR_PROPERTY; >- return null; >- } >- }; >- >- InputDialog dlg = new InputDialog(getShell(), Messages.DEFAULT_VALUE_LABEL, >- Messages.EDIT_DEFAULT_VALUE_LABEL, _listDefault.getSelection()[0], validator); >- >- int choice = dlg.open(); >- if (choice == Window.OK) >+ /** >+ * Turn the enumeration controls (the list of valid enums and the 'add' >+ * button on/off >+ */ >+ private void enableEnumControls(boolean b) > { >- String newDef = dlg.getValue().trim(); >+ _listValidEnum.setEnabled(b); >+ if (b) >+ selectedEnumeration(); >+ else >+ { >+ _buttonAddEnum.setEnabled(b); >+ _buttonEditEnum.setEnabled(b); >+ _buttonDelEnum.setEnabled(b); >+ } >+ } > >- if (newDef.equals("")) >- return; // Do not allow empty value >+ /** Turn the min/max controls on/off */ >+ private void enableRangeControls(boolean b) >+ { >+ _labelMin.setEnabled(b); >+ _labelMax.setEnabled(b); >+ _fieldMin.setEnabled(b); >+ _fieldMax.setEnabled(b); >+ } > >- if (_listDefault.indexOf(newDef) == -1) >- { // Do not duplicate >- int[] indices = _listDefault.getSelectionIndices(); >- _listDefault.remove(indices); >- _listDefault.add(newDef, indices[0]); >- } >+ protected MetadataDescriptor createMetaDataDescriptor() >+ { >+ MetadataDescriptor propertyMetaDataDescriptor = MetaDataUtils >+ .createMetaDataDescriptor(_capabilityDomain); >+ return propertyMetaDataDescriptor; >+ } > >- // If the restriction is 'enumerated', ensure the added default >- // is legal >- // by adding it to the enumeration if it isn't already there >- if (_propValidValues.getSelection()) >- { >- if (!Arrays.asList(_listValidEnum.getItems()).contains(newDef)) >- { >- _listValidEnum.add(newDef); >- } >- // TODO Remove the old, pre-edit from the enumeration? >- } >- } >- } >- >- protected void delDefault() >- { >- int[] indices = _listDefault.getSelectionIndices(); >- _listDefault.remove(indices); >- selectedDefault(); >- } >- >- /** >- * >- */ >- protected void selectedDefault() >- { >- _buttonDelDefault.setEnabled(_listDefault.getSelectionCount() > 0); >- _buttonEditDefault.setEnabled(_listDefault.getSelectionCount() > 0); >- } >- >- protected void selectedEnumeration() >- { >- _buttonAddEnum.setEnabled(_propValidValues.getSelection()); >- _buttonDelEnum.setEnabled(_listValidEnum.getSelectionCount() > 0); >- _buttonEditEnum.setEnabled(_listValidEnum.getSelectionCount() > 0); >- } >- >- protected void selectedRange() >- { >- _fieldMin.setEnabled(_propValidRange.getSelection()); >- _fieldMax.setEnabled(_propValidRange.getSelection()); >- } >- >- protected void createButtonsForButtonBar(Composite parent) >- { >- // Because we call Dialog.createButton(), rather than Button's >- // constructor, >- // we get Dialog's handling of buttons (which is to call >- // buttonPressed()). >- createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, >- true); >- createButton(parent, IDialogConstants.CANCEL_ID, >- IDialogConstants.CANCEL_LABEL, false); >- initializeWidgets(); >- } >- >- private void initializeWidgets() >- { >- PropertyType metadata = _property.getMetaData(); >- if (metadata == null) >- { >- _propUnlimited.setSelection(true); >- selectedDefault(); >- enableDisableOnValidationType(); >- return; >- } >- >- Object[] validValues = MetaDataUtils.getValidValues(metadata >- .getValidValues()); >- if (validValues.length != 0) >- { >- for (int i = 0; i < validValues.length; i++) >- _listValidEnum.add((String) validValues[i]); >- _propValidValues.setSelection(true); >- selectedEnumeration(); >- } >- >- if (metadata.getValidValueRange() != null) >- { >- _fieldMin.setText((String) metadata.getValidValueRange() >- .getLowerBound()); >- _fieldMax.setText((String) metadata.getValidValueRange() >- .getUpperBound()); >- _propValidRange.setSelection(true); >- selectedRange(); >- } >- >- Object[] defaultValues = MetaDataUtils.getStaticValues(metadata >- .getStaticValues()); >- if (defaultValues.length != 0) >- { >- for (int i = 0; i < defaultValues.length; i++) >- _listDefault.add((String) defaultValues[i]); >- } >- >- selectedDefault(); >- enableDisableOnValidationType(); >- } >- >- protected void okPressed() >- { >- >- PropertyMetaDataDescriptor propertyMetaDataDescriptor = _capabilityDomain >- .getMetaDataDescriptor(); >- if (propertyMetaDataDescriptor == null) >- { >- propertyMetaDataDescriptor = createMetaDataDescriptor(); >- _capabilityDomain.setMetaDataDescriptor(propertyMetaDataDescriptor); >- } >- >- PropertyType metadata = _property.getMetaData(); >- if (metadata == null) >- { >- metadata = propertyMetaDataDescriptor.createNewPropertyType(); >- _property.setMetaData(metadata); >- String ns = _property.getElement().getTargetNamespace(); >- String name = XsdUtils.getName(_property.getElement()); >- String prefix = propertyMetaDataDescriptor.getOrCreatePrefix(ns); >- metadata.setName(new QName(ns, name, prefix)); >- } >- >- metadata.setStaticValues(null); >- metadata.setValidValueRange(null); >- metadata.setValidValues(null); >- >- if (_propValidValues.getSelection()) >- { >- if (_listValidEnum.getItemCount() > 0) >- { >- ValidValuesType validValuesType = _rmdFactory >- .createValidValuesType(); >- FeatureMap fm = validValuesType.getAny(); >- for (int i = 0; i < _listValidEnum.getItemCount(); i++) >- { >- String value = _listValidEnum.getItem(i); >- addValue(fm, value); >- } >- metadata.setValidValues(validValuesType); >- } >- } >- else if (_propValidRange.getSelection()) >- { >- ValidValueRangeType validValueRange = _rmdFactory >- .createValidValueRangeType(); >- validValueRange.setLowerBound(_fieldMin.getText()); >- validValueRange.setUpperBound(_fieldMax.getText()); >- metadata.setValidValueRange(validValueRange); >- } >- >- if (_listDefault.getItemCount() > 0) >- { >- StaticValuesType staticValuesType = _rmdFactory >- .createStaticValuesType(); >- FeatureMap fm = staticValuesType.getAny(); >- for (int i = 0; i < _listDefault.getItemCount(); i++) >- { >- String value = _listDefault.getItem(i); >- addValue(fm, value); >- } >- metadata.setStaticValues(staticValuesType); >- } >- >- super.okPressed(); >- } >- >- private void addValue(FeatureMap fm, String value) >- { >- String namespace = _property.getElement().getTargetNamespace(); >- String name = XsdUtils.getName(_property.getElement()); >- EStructuralFeature esf = _extendedMetaData.demandFeature(namespace, >- name, true); >- AnyType anyType = XMLTypeFactory.eINSTANCE.createAnyType(); >- FeatureMapUtil.addText(anyType.getAny(), value); >- fm.add(esf, anyType); >- } >- >- private void setSpan(Control c, int newSpan) >- { >- GridData gd = new GridData(); >- gd.horizontalSpan = newSpan; >- c.setLayoutData(gd); >- } >- >- /** >- * Turn the extra-schema validation extra controls on/off based on radio >- * button selection >- */ >- private void enableDisableOnValidationType() >- { >- enableEnumControls(_propValidValues.getSelection()); >- enableRangeControls(_propValidRange.getSelection()); >- } >- >- /** >- * Turn the enumeration controls (the list of valid enums and the 'add' >- * button on/off >- */ >- private void enableEnumControls(boolean b) >- { >- _listValidEnum.setEnabled(b); >- if (b) >- selectedEnumeration(); >- else >- { >- _buttonAddEnum.setEnabled(b); >- _buttonEditEnum.setEnabled(b); >- _buttonDelEnum.setEnabled(b); >- } >- } >- >- /** Turn the min/max controls on/off */ >- private void enableRangeControls(boolean b) >- { >- _labelMin.setEnabled(b); >- _labelMax.setEnabled(b); >- _fieldMin.setEnabled(b); >- _fieldMax.setEnabled(b); >- } >- >- protected PropertyMetaDataDescriptor createMetaDataDescriptor() >- { >- PropertyMetaDataDescriptor propertyMetaDataDescriptor = MetaDataUtils >- .createMetaDataDescriptor(_capabilityDomain); >- return propertyMetaDataDescriptor; >- } >- >- // NOTE: Fix for Bugzilla Bug 167370 : Default values dialog in capability editor does not accept values >- // with spaces or numbers and is not validated. >- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=167370 >- private boolean isValidUserInputAgainstPropertyType(String userInput) >- { >- String propType = XsdUtils.getType(_property.getElement()); >- if(propType == null || propType.equals("")) >- return true; >- if(propType.equals("integer") || propType.equals("int")) >- { >- try{ >- Integer.parseInt(userInput); >- }catch(Exception e){ >- return false; >- } >- } >- else if(propType.equals("float")) >- { >- try{ >- Float.parseFloat(userInput); >- }catch(Exception e){ >- return false; >- } >- } >- else if(propType.equals("short")) >- { >- try{ >- Short.parseShort(userInput); >- }catch(Exception e){ >- return false; >- } >- } >- else if(propType.equals("long")) >- { >- try{ >- Long.parseLong(userInput); >- }catch(Exception e){ >- return false; >- } >- } >- else if(propType.equals("double")) >- { >- try{ >- Double.parseDouble(userInput); >- }catch(Exception e){ >- return false; >- } >- } >- else if(propType.equals("boolean")) >- { >- if(!userInput.equals("true")) >- if(!userInput.equals("false")) >- return false; >- } >- else if(propType.equals("NCName")) >- { >- return Validation.isNCName(userInput); >- } >- return true; >- } >+ // NOTE: Fix for Bugzilla Bug 167370 : Default values dialog in capability >+ // editor does not accept values >+ // with spaces or numbers and is not validated. >+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=167370 >+ private boolean isValidUserInputAgainstPropertyType(String userInput) >+ { >+ String propType = XsdUtils.getType(_property.getElement()); >+ if (propType == null || propType.equals("")) >+ return true; >+ if (propType.equals("integer") || propType.equals("int")) >+ { >+ try >+ { >+ Integer.parseInt(userInput); >+ } catch (Exception e) >+ { >+ return false; >+ } >+ } >+ else if (propType.equals("float")) >+ { >+ try >+ { >+ Float.parseFloat(userInput); >+ } catch (Exception e) >+ { >+ return false; >+ } >+ } >+ else if (propType.equals("short")) >+ { >+ try >+ { >+ Short.parseShort(userInput); >+ } catch (Exception e) >+ { >+ return false; >+ } >+ } >+ else if (propType.equals("long")) >+ { >+ try >+ { >+ Long.parseLong(userInput); >+ } catch (Exception e) >+ { >+ return false; >+ } >+ } >+ else if (propType.equals("double")) >+ { >+ try >+ { >+ Double.parseDouble(userInput); >+ } catch (Exception e) >+ { >+ return false; >+ } >+ } >+ else if (propType.equals("boolean")) >+ { >+ if (!userInput.equals("true")) >+ if (!userInput.equals("false")) >+ return false; >+ } >+ else if (propType.equals("NCName")) >+ { >+ return Validation.isNCName(userInput); >+ } >+ return true; >+ } > > } >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/overview/internal/ChangeCapabilityDescriptionCommand.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.editor.capability/src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/overview/internal/ChangeCapabilityDescriptionCommand.java,v >retrieving revision 1.3 >diff -u -r1.3 ChangeCapabilityDescriptionCommand.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/overview/internal/ChangeCapabilityDescriptionCommand.java 9 Jan 2007 19:51:45 -0000 1.3 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/overview/internal/ChangeCapabilityDescriptionCommand.java 20 Jan 2007 13:33:30 -0000 >@@ -42,8 +42,8 @@ > public ChangeCapabilityDescriptionCommand( > CapabilityDomain capabilityDomain, String newDescription) > { >- _capabilityDomain = capabilityDomain; >- _newDescription = newDescription; >+ _capabilityDomain = capabilityDomain; >+ _newDescription = newDescription; > } > > /** >@@ -51,44 +51,43 @@ > */ > public void execute() > { >+ if (_capabilityDomain.getDescriptionNode() != null) >+ { >+ _capabilityDomain.getDescriptionNode().setData(_newDescription); >+ _capabilityDomain.getCapability().setDescription(_newDescription); >+ return; >+ } > >- if (_capabilityDomain.getDescriptionNode() != null) >- { >- _capabilityDomain.getDescriptionNode().setData(_newDescription); >- _capabilityDomain.getCapability().setDescription(_newDescription); >- return; >- } >- >- Definition definition = _capabilityDomain.getDefinition(); >- XSDSchema tnsSchema = WsdlUtils.createOrFindSchema(definition, >- definition.getTargetNamespace()); >- List annotations = tnsSchema.getAnnotations(); >- Text descriptionNode = null; >- if (annotations != null && annotations.size() != 0) >- { >- XSDAnnotation annotation = (XSDAnnotation) annotations.get(0); >- Element documentation = annotation.createUserInformation(null); >- annotation.getElement().appendChild(documentation); >- descriptionNode = documentation.getOwnerDocument().createTextNode(_newDescription); >- documentation.appendChild(descriptionNode); >- } >- else >- { >- descriptionNode = createNewAnnotation(tnsSchema); >- } >- _capabilityDomain.setDescriptionNode(descriptionNode); >- _capabilityDomain.getCapability().setDescription(_newDescription); >+ Definition definition = _capabilityDomain.getCapability().getDefinition(); >+ XSDSchema tnsSchema = WsdlUtils.createOrFindSchema(definition, >+ definition.getTargetNamespace()); >+ List annotations = tnsSchema.getAnnotations(); >+ Text descriptionNode = null; >+ if (annotations != null && annotations.size() != 0) >+ { >+ XSDAnnotation annotation = (XSDAnnotation) annotations.get(0); >+ Element documentation = annotation.createUserInformation(null); >+ annotation.getElement().appendChild(documentation); >+ descriptionNode = documentation.getOwnerDocument().createTextNode(_newDescription); >+ documentation.appendChild(descriptionNode); >+ } >+ else >+ { >+ descriptionNode = createNewAnnotation(tnsSchema); >+ } >+ _capabilityDomain.setDescriptionNode(descriptionNode); >+ _capabilityDomain.getCapability().setDescription(_newDescription); > } > > private Text createNewAnnotation(XSDSchema schema) > { >- XSDAnnotation annotation = XSDFactory.eINSTANCE.createXSDAnnotation(); >- schema.getContents().add(0, annotation); >- Element documentation = annotation.createUserInformation(null); >- annotation.getElement().appendChild(documentation); >- Text node = documentation.getOwnerDocument().createTextNode(_newDescription); >- documentation.appendChild(node); >- return node; >+ XSDAnnotation annotation = XSDFactory.eINSTANCE.createXSDAnnotation(); >+ schema.getContents().add(0, annotation); >+ Element documentation = annotation.createUserInformation(null); >+ annotation.getElement().appendChild(documentation); >+ Text node = documentation.getOwnerDocument().createTextNode(_newDescription); >+ documentation.appendChild(node); >+ return node; > } > > } >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/overview/internal/ChangeCapabilityNameCommand.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.editor.capability/src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/overview/internal/ChangeCapabilityNameCommand.java,v >retrieving revision 1.4 >diff -u -r1.4 ChangeCapabilityNameCommand.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/overview/internal/ChangeCapabilityNameCommand.java 9 Jan 2007 19:51:44 -0000 1.4 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/overview/internal/ChangeCapabilityNameCommand.java 20 Jan 2007 13:33:31 -0000 >@@ -16,7 +16,7 @@ > > import org.eclipse.tptp.wsdm.tooling.editor.capability.internal.CapabilityDomain; > import org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability; >-import org.eclipse.tptp.wsdm.tooling.util.internal.PropertyMetaDataDescriptor; >+import org.eclipse.tptp.wsdm.tooling.model.capabilities.impl.MetadataDescriptor; > import org.eclipse.tptp.wsdm.tooling.util.internal.WsdlUtils; > import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmConstants; > import org.eclipse.tptp.wsdm.tooling.util.internal.XsdUtils; >@@ -50,8 +50,8 @@ > public ChangeCapabilityNameCommand(CapabilityDomain capabilityDomain, > String newName) > { >- _capabilityDomain = capabilityDomain; >- _newName = newName; >+ _capabilityDomain = capabilityDomain; >+ _newName = newName; > } > > /** >@@ -59,59 +59,61 @@ > */ > public void execute() > { >- Capability capability = _capabilityDomain.getCapability(); >- capability.setName(_newName); >- Definition definition = _capabilityDomain.getDefinition(); >- String namespace = definition.getTargetNamespace(); >- definition.setQName(new QName(namespace, _newName)); >- >- PortType pt = WsdlUtils.getPortType(definition); >- if (pt != null) >- pt.setQName(new QName(namespace, _newName + "PortType")); >- >- changeMetadescriptorName(pt); >- >- changeResourcePropertiesName(pt); >+ Capability capability = _capabilityDomain.getCapability(); >+ capability.setName(_newName); >+ Definition definition = capability.getDefinition(); >+ String namespace = definition.getTargetNamespace(); >+ definition.setQName(new QName(namespace, _newName)); >+ >+ PortType pt = WsdlUtils.getPortType(definition); >+ if (pt != null) >+ pt.setQName(new QName(namespace, _newName + "PortType")); >+ >+ changeMetadescriptorName(pt); >+ >+ changeResourcePropertiesName(pt); > } > > private void changeMetadescriptorName(PortType pt) > { >- PropertyMetaDataDescriptor metaDataDescriptor = _capabilityDomain.getMetaDataDescriptor(); >- if (metaDataDescriptor != null) >- { >- String metaDataDescriptorName = _newName + "Descriptor"; >- metaDataDescriptor.setMetadataDescriptorName(metaDataDescriptorName); >- if (pt != null) >- { >- Attr attribute = pt.getElement().getAttributeNodeNS( >- WsdmConstants.WSRMD_NS, >- WsdlUtils.METADATA_DESCRIPTOR_KEY); >- if (attribute != null) >- attribute.setNodeValue(metaDataDescriptorName); >- } >- } >+ MetadataDescriptor metaDataDescriptor = _capabilityDomain.getCapability().getMetadata(); >+ if (metaDataDescriptor != null) >+ { >+ String metaDataDescriptorName = _newName + "Descriptor"; >+ metaDataDescriptor.setMetadataDescriptorName(metaDataDescriptorName); >+ String prefix = metaDataDescriptor.getPrefix(_capabilityDomain.getCapability().getNamespace()); >+ metaDataDescriptor.getMetadataDescriptorType().setInterface(prefix+":"+_newName+"PortType"); >+ if (pt != null) >+ { >+ Attr attribute = pt.getElement().getAttributeNodeNS( >+ WsdmConstants.WSRMD_NS, >+ WsdlUtils.METADATA_DESCRIPTOR_KEY); >+ if (attribute != null) >+ attribute.setNodeValue(metaDataDescriptorName); >+ } >+ } > } > > private void changeResourcePropertiesName(PortType pt) > { >- Definition definition = _capabilityDomain.getDefinition(); >- XSDElementDeclaration resourcePropertyElement = _capabilityDomain.getResourcePropertyElement(); >- if (resourcePropertyElement != null) >- { >- String rpElementName = _newName + "Properties"; >- XsdUtils.setName(resourcePropertyElement, rpElementName); >- if (pt != null) >- { >- Attr attribute = pt.getElement().getAttributeNodeNS( >- WsdmConstants.WSRP_NS, >- WsdlUtils.RESOURCE_PROPERTIES_ELEMENT_KEY); >- String rpElementPrefix = WsdlUtils.getPrefix(definition, >- resourcePropertyElement.getTargetNamespace()); >- if (attribute != null) >- attribute.setNodeValue(rpElementPrefix + ":" >- + rpElementName); >- } >- } >+ Definition definition = _capabilityDomain.getCapability().getDefinition(); >+ XSDElementDeclaration resourcePropertyElement = _capabilityDomain.getResourcePropertyElement(); >+ if (resourcePropertyElement != null) >+ { >+ String rpElementName = _newName + "Properties"; >+ XsdUtils.setName(resourcePropertyElement, rpElementName); >+ if (pt != null) >+ { >+ Attr attribute = pt.getElement().getAttributeNodeNS( >+ WsdmConstants.WSRP_NS, >+ WsdlUtils.RESOURCE_PROPERTIES_ELEMENT_KEY); >+ String rpElementPrefix = WsdlUtils.getPrefix(definition, >+ resourcePropertyElement.getTargetNamespace()); >+ if (attribute != null) >+ attribute.setNodeValue(rpElementPrefix + ":" >+ + rpElementName); >+ } >+ } > } > > } >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/overview/internal/ChangeCapabilityNamespaceCommand.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.editor.capability/src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/overview/internal/ChangeCapabilityNamespaceCommand.java,v >retrieving revision 1.5 >diff -u -r1.5 ChangeCapabilityNamespaceCommand.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/overview/internal/ChangeCapabilityNamespaceCommand.java 9 Jan 2007 19:51:45 -0000 1.5 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/overview/internal/ChangeCapabilityNamespaceCommand.java 20 Jan 2007 13:33:31 -0000 >@@ -18,11 +18,8 @@ > > import org.eclipse.emf.common.util.EMap; > import org.eclipse.emf.ecore.impl.EStringToStringMapEntryImpl; >-import org.eclipse.emf.ecore.xml.type.internal.QName; > 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.model.metadataDescriptor.PropertyType; >-import org.eclipse.tptp.wsdm.tooling.util.internal.PropertyMetaDataDescriptor; >+import org.eclipse.tptp.wsdm.tooling.model.capabilities.impl.MetadataDescriptor; > import org.eclipse.tptp.wsdm.tooling.util.internal.WsdlUtils; > import org.eclipse.wst.wsdl.Definition; > import org.eclipse.wst.wsdl.Message; >@@ -58,44 +55,44 @@ > public ChangeCapabilityNamespaceCommand(CapabilityDomain capabilityDomain, > String newNS) > { >- _capabilityDomain = capabilityDomain; >- _oldNamespace = capabilityDomain.getCapability().getNamespace(); >- _newNamespace = newNS; >+ _capabilityDomain = capabilityDomain; >+ _oldNamespace = capabilityDomain.getCapability().getNamespace(); >+ _newNamespace = newNS; > } > > private void changeAllOldNSInSchemas() > { >- Definition definition = _capabilityDomain.getDefinition(); >- XSDSchema[] schemas = WsdlUtils.getXSDSchemas(definition); >- if (schemas == null) >- { >- // No WSDL Types found >- return; >- } >- >- for (int i = 0; i < schemas.length; i++) >- changeNS(schemas[i]); >+ Definition definition = _capabilityDomain.getCapability().getDefinition(); >+ XSDSchema[] schemas = WsdlUtils.getXSDSchemas(definition); >+ if (schemas == null) >+ { >+ // No WSDL Types found >+ return; >+ } >+ >+ for (int i = 0; i < schemas.length; i++) >+ changeNS(schemas[i]); > } > > private void changeNS(XSDSchema schema) > { >- changeAllOldNS(schema); >- if (schema.getTargetNamespace().equals(_oldNamespace)) >- schema.setTargetNamespace(_newNamespace); >+ changeAllOldNS(schema); >+ if (schema.getTargetNamespace().equals(_oldNamespace)) >+ schema.setTargetNamespace(_newNamespace); > } > > private void changeAllOldNS(XSDSchema schema) > { >- Map nsMap = schema.getQNamePrefixToNamespaceMap(); >- Iterator keyIt = nsMap.keySet().iterator(); >- Iterator valueIt = nsMap.values().iterator(); >- while (keyIt.hasNext()) >- { >- String key = (String) keyIt.next(); >- String value = (String) valueIt.next(); >- if (value.equals(_oldNamespace)) >- nsMap.put(key, _newNamespace); >- } >+ Map nsMap = schema.getQNamePrefixToNamespaceMap(); >+ Iterator keyIt = nsMap.keySet().iterator(); >+ Iterator valueIt = nsMap.values().iterator(); >+ while (keyIt.hasNext()) >+ { >+ String key = (String) keyIt.next(); >+ String value = (String) valueIt.next(); >+ if (value.equals(_oldNamespace)) >+ nsMap.put(key, _newNamespace); >+ } > } > > /** >@@ -103,141 +100,122 @@ > */ > public void execute() > { >- changeAllOldNSInSchemas(); >- changeAllOldNSInDef(); >- changeAllMessagesQName(); >- changeAllOldNSInMetadata(); >- changePropNS(); >- >- _capabilityDomain.getCapability().setNamespace(_newNamespace); >- Definition definition = _capabilityDomain.getDefinition(); >- String name = definition.getQName().getLocalPart(); >- definition.setQName(new javax.xml.namespace.QName(_newNamespace, name)); >- definition.setTargetNamespace(_newNamespace); >+ changeAllOldNSInSchemas(); >+ changeAllOldNSInDef(); >+ changeAllMessagesQName(); >+ changeAllOldNSInMetadata(); >+ changePropNS(); >+ >+ _capabilityDomain.getCapability().setNamespace(_newNamespace); >+ Definition definition = _capabilityDomain.getCapability().getDefinition(); >+ String name = definition.getQName().getLocalPart(); >+ definition.setQName(new javax.xml.namespace.QName(_newNamespace, name)); >+ definition.setTargetNamespace(_newNamespace); > } > > private void changePropNS() > { >- List propSchemas = _capabilityDomain.getPropertiesSchemas(); >- if(propSchemas == null) >- return; >- for(int i=0;i<propSchemas.size();i++) >- { >- XSDSchema propSchema = (XSDSchema) propSchemas.get(i); >- changeNS(propSchema); >- } >+ List propSchemas = _capabilityDomain.getPropertiesSchemas(); >+ if(propSchemas == null) >+ return; >+ for(int i=0;i<propSchemas.size();i++) >+ { >+ XSDSchema propSchema = (XSDSchema) propSchemas.get(i); >+ changeNS(propSchema); >+ } > } > > private void changeAllOldNSInDef() > { >- Definition definition = _capabilityDomain.getDefinition(); >- >- // Change the definition element >- NamedNodeMap map = definition.getElement().getAttributes(); >- for (int i = 0; i < map.getLength(); i++) >- { >- if (map.item(i) instanceof Attr) >- { >- Attr attribute = (Attr) map.item(i); >- if (attribute.getNodeValue().equals(_oldNamespace)) >- attribute.setNodeValue(_newNamespace); >- } >- } >- >- // Change the definition namespace map >- Map nsMap = definition.getNamespaces(); >- Iterator keyIt = nsMap.keySet().iterator(); >- while(keyIt.hasNext()) >- { >- Object key = keyIt.next(); >- String namespace = (String) nsMap.get(key); >- if(namespace.equals(_oldNamespace)) >- nsMap.put(key, _newNamespace); >- } >+ Definition definition = _capabilityDomain.getCapability().getDefinition(); >+ >+ // Change the definition element >+ NamedNodeMap map = definition.getElement().getAttributes(); >+ for (int i = 0; i < map.getLength(); i++) >+ { >+ if (map.item(i) instanceof Attr) >+ { >+ Attr attribute = (Attr) map.item(i); >+ if (attribute.getNodeValue().equals(_oldNamespace)) >+ attribute.setNodeValue(_newNamespace); >+ } >+ } >+ >+ // Change the definition namespace map >+ Map nsMap = definition.getNamespaces(); >+ Iterator keyIt = nsMap.keySet().iterator(); >+ while(keyIt.hasNext()) >+ { >+ Object key = keyIt.next(); >+ String namespace = (String) nsMap.get(key); >+ if(namespace.equals(_oldNamespace)) >+ nsMap.put(key, _newNamespace); >+ } > } > > private void changeAllOldNSInMetadata() > { >- PropertyMetaDataDescriptor metaDataDescriptor = _capabilityDomain.getMetaDataDescriptor(); >- if (metaDataDescriptor == null) >- return; >- >- changeInAllNamespaces(); >- changeInAllProperties(); >+ MetadataDescriptor metaDataDescriptor = _capabilityDomain.getCapability().getMetadata(); >+ if (metaDataDescriptor == null) >+ return; >+ >+ changeInAllNamespaces(); >+ >+ String capabilityFileName = _capabilityDomain.getCapabilityIFile().getName(); >+ metaDataDescriptor.getMetadataDescriptorType().setWsdlLocation(_newNamespace+" "+capabilityFileName); > } > > private void changeInAllNamespaces() > { >- PropertyMetaDataDescriptor metaDataDescriptor = _capabilityDomain.getMetaDataDescriptor(); >- if (metaDataDescriptor.getDocumentRoot().getDefinitions().getTargetNamespace().equals(_oldNamespace)) >- metaDataDescriptor.getDocumentRoot().getDefinitions().setTargetNamespace(_newNamespace); >- >- EMap map = metaDataDescriptor.getDocumentRoot().getXMLNSPrefixMap(); >- Iterator keyIt = map.iterator(); >- while (keyIt.hasNext()) >- { >- Object object = keyIt.next(); >- if (object instanceof EStringToStringMapEntryImpl) >- { >- EStringToStringMapEntryImpl entry = (EStringToStringMapEntryImpl) object; >- if (entry.getValue().equals(_oldNamespace)) >- entry.setValue(_newNamespace); >- } >- } >- } >- >- private void changeInAllProperties() >- { >- PropertyMetaDataDescriptor metaDataDescriptor = _capabilityDomain.getMetaDataDescriptor(); >- String prefix = metaDataDescriptor.getPrefix(_newNamespace); >- List properties = _capabilityDomain.getCapability().getProperties(); >- for (int i = 0; i < properties.size(); i++) >- { >- Property property = (Property) properties.get(i); >- PropertyType metadata = property.getMetaData(); >- if(metadata != null) >- { >- QName qname = (QName) metadata.getName(); >- if(qname.getNamespaceURI().equals(_oldNamespace)) >- { >- qname.setNamespaceURI(_newNamespace); >- qname.setPrefix(prefix); >- } >- } >- } >+ MetadataDescriptor metaDataDescriptor = _capabilityDomain.getCapability().getMetadata(); >+ if (metaDataDescriptor.getDocumentRoot().getDefinitions().getTargetNamespace().equals(_oldNamespace)) >+ metaDataDescriptor.getDocumentRoot().getDefinitions().setTargetNamespace(_newNamespace); >+ >+ EMap map = metaDataDescriptor.getDocumentRoot().getXMLNSPrefixMap(); >+ Iterator keyIt = map.iterator(); >+ while (keyIt.hasNext()) >+ { >+ Object object = keyIt.next(); >+ if (object instanceof EStringToStringMapEntryImpl) >+ { >+ EStringToStringMapEntryImpl entry = (EStringToStringMapEntryImpl) object; >+ if (entry.getValue().equals(_oldNamespace)) >+ entry.setValue(_newNamespace); >+ } >+ } > } > > private void changeAllMessagesQName() > { >- Definition definition = _capabilityDomain.getDefinition(); >- List messages = definition.getEMessages(); >- if(messages == null) >- return; >- for(int i=0;i<messages.size();i++) >- { >- Message message = (Message) messages.get(i); >- if(!message.getEnclosingDefinition().equals(definition)) >- continue; >- String localName = message.getQName().getLocalPart(); >- message.setQName(new javax.xml.namespace.QName(_newNamespace, localName)); >- changePartsQName(message.getEParts()); >- } >+ Definition definition = _capabilityDomain.getCapability().getDefinition(); >+ List messages = definition.getEMessages(); >+ if(messages == null) >+ return; >+ for(int i=0;i<messages.size();i++) >+ { >+ Message message = (Message) messages.get(i); >+ if(!message.getEnclosingDefinition().equals(definition)) >+ continue; >+ String localName = message.getQName().getLocalPart(); >+ message.setQName(new javax.xml.namespace.QName(_newNamespace, localName)); >+ changePartsQName(message.getEParts()); >+ } > } > > private void changePartsQName(List parts) > { >- if(parts == null) >- return; >- for(int i=0;i<parts.size();i++) >- { >- Part part = (Part) parts.get(i); >- if(part.getElementDeclaration()!=null) >- part.setElementName(new javax.xml.namespace.QName(part.getElementDeclaration().getTargetNamespace(), >- part.getElementDeclaration().getName())); >- if(part.getTypeDefinition()!=null) >- part.setTypeName(new javax.xml.namespace.QName(part.getTypeDefinition().getTargetNamespace(), >- part.getTypeDefinition().getName())); >- } >+ if(parts == null) >+ return; >+ for(int i=0;i<parts.size();i++) >+ { >+ Part part = (Part) parts.get(i); >+ if(part.getElementDeclaration()!=null) >+ part.setElementName(new javax.xml.namespace.QName(part.getElementDeclaration().getTargetNamespace(), >+ part.getElementDeclaration().getName())); >+ if(part.getTypeDefinition()!=null) >+ part.setTypeName(new javax.xml.namespace.QName(part.getTypeDefinition().getTargetNamespace(), >+ part.getTypeDefinition().getName())); >+ } > } > > } >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/topic/internal/NewRootTopicDialog.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.editor.capability/src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/topic/internal/NewRootTopicDialog.java,v >retrieving revision 1.3 >diff -u -r1.3 NewRootTopicDialog.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/topic/internal/NewRootTopicDialog.java 9 Jan 2007 19:51:44 -0000 1.3 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/topic/internal/NewRootTopicDialog.java 20 Jan 2007 13:33:42 -0000 >@@ -21,125 +21,125 @@ > import org.eclipse.swt.widgets.Label; > import org.eclipse.swt.widgets.Shell; > import org.eclipse.swt.widgets.Text; >+import org.eclipse.tptp.wsdm.tooling.model.capabilities.CapabilitiesFactory; > import org.eclipse.tptp.wsdm.tooling.model.capabilities.Topic; > import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.topic.internal.Messages; >-import org.eclipse.tptp.wsdm.tooling.util.internal.TopicUtils; > > /** > * > * Popup dialog to create new root topic. >- * >+ * > */ > > public class NewRootTopicDialog extends Dialog > { > >- private final String _title; >+ private final String _title; > >- private Text _topicSpaceText; >+ private Text _topicSpaceText; > >- private Text _rootTopicNameText; >+ private Text _rootTopicNameText; > >- private String _topicNamespace; >+ private String _topicNamespace; > >- private Topic _rootTopic; >- >- /** >- * Create a new dialog for root topic. >- * >- * @param parentShell >- * Shell. >- * >- * @param dialogTitle >- * Title of this dialog. >- * >- * @param topicNamespace >- * TopicNamespace to which this root topic will be added. >- */ >- protected NewRootTopicDialog(Shell parentShell, String dialogTitle, >- String topicNamespace) >- { >- super(parentShell); >- _title = dialogTitle; >- _topicNamespace = topicNamespace; >- } >- >- protected void configureShell(Shell shell) >- { >- super.configureShell(shell); >- if (_title != null) >- shell.setText(_title); >- } >- >- protected Control createDialogArea(Composite parent) >- { >- Composite composite = (Composite) super.createDialogArea(parent); >- >- GridLayout layout = new GridLayout(2, true); >- composite.setLayout(layout); >- >- Label topicSpaceLabel = new Label(composite, SWT.NONE); >- topicSpaceLabel.setText(Messages.TOPIC_NAMESPACE); >- >- _topicSpaceText = new Text(composite, SWT.SINGLE | SWT.BORDER); >- _topicSpaceText.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL >- | GridData.HORIZONTAL_ALIGN_FILL)); >- >- Label rootTopicNameLabel = new Label(composite, SWT.NONE); >- rootTopicNameLabel.setText(Messages.ROOT_TOPIC_NAME); >- >- _rootTopicNameText = new Text(composite, SWT.SINGLE | SWT.BORDER); >- _rootTopicNameText.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL >- | GridData.HORIZONTAL_ALIGN_FILL)); >- >- initializeControls(); >- hookAllListeners(); >- >- applyDialogFont(composite); >- >- return composite; >- } >- >- protected Control createButtonBar(Composite parent) >- { >- Control ret = super.createButtonBar(parent); >- return ret; >- } >- >- private void initializeControls() >- { >- _topicSpaceText.setText(_topicNamespace); >- _rootTopicNameText.setText("RootTopic"); >- } >- >- private void hookAllListeners() >- { >- >- } >- >- protected void okPressed() >- { >- _rootTopic = TopicUtils.createNewTopic(); >- _rootTopic.setName(_rootTopicNameText.getText()); >- _topicNamespace = _topicSpaceText.getText(); >- super.okPressed(); >- } >- >- /** >- * >- * @return New root topic. >- */ >- public Topic getRootTopic() >- { >- return _rootTopic; >- } >- >- /** >- * >- * @return Topic namespace. >- */ >- public String getTopicNamespace() >- { >- return _topicNamespace; >- } >+ private Topic _rootTopic; >+ >+ /** >+ * Create a new dialog for root topic. >+ * >+ * @param parentShell >+ * Shell. >+ * >+ * @param dialogTitle >+ * Title of this dialog. >+ * >+ * @param topicNamespace >+ * TopicNamespace to which this root topic will be added. >+ */ >+ protected NewRootTopicDialog(Shell parentShell, String dialogTitle, >+ String topicNamespace) >+ { >+ super(parentShell); >+ _title = dialogTitle; >+ _topicNamespace = topicNamespace; >+ } >+ >+ protected void configureShell(Shell shell) >+ { >+ super.configureShell(shell); >+ if (_title != null) >+ shell.setText(_title); >+ } >+ >+ protected Control createDialogArea(Composite parent) >+ { >+ Composite composite = (Composite) super.createDialogArea(parent); >+ >+ GridLayout layout = new GridLayout(2, true); >+ composite.setLayout(layout); >+ >+ Label topicSpaceLabel = new Label(composite, SWT.NONE); >+ topicSpaceLabel.setText(Messages.TOPIC_NAMESPACE); >+ >+ _topicSpaceText = new Text(composite, SWT.SINGLE | SWT.BORDER); >+ _topicSpaceText.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL >+ | GridData.HORIZONTAL_ALIGN_FILL)); >+ >+ Label rootTopicNameLabel = new Label(composite, SWT.NONE); >+ rootTopicNameLabel.setText(Messages.ROOT_TOPIC_NAME); >+ >+ _rootTopicNameText = new Text(composite, SWT.SINGLE | SWT.BORDER); >+ _rootTopicNameText.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL >+ | GridData.HORIZONTAL_ALIGN_FILL)); >+ >+ initializeControls(); >+ hookAllListeners(); >+ >+ applyDialogFont(composite); >+ >+ return composite; >+ } >+ >+ protected Control createButtonBar(Composite parent) >+ { >+ Control ret = super.createButtonBar(parent); >+ return ret; >+ } >+ >+ private void initializeControls() >+ { >+ _topicSpaceText.setText(_topicNamespace); >+ _rootTopicNameText.setText("RootTopic"); >+ } >+ >+ private void hookAllListeners() >+ { >+ >+ } >+ >+ protected void okPressed() >+ { >+ _rootTopic = CapabilitiesFactory.eINSTANCE.createTopic(); >+ _rootTopic.setName(_rootTopicNameText.getText()); >+ _topicNamespace = _topicSpaceText.getText(); >+ super.okPressed(); >+ } >+ >+ /** >+ * >+ * @return New root topic. >+ */ >+ public Topic getRootTopic() >+ { >+ return _rootTopic; >+ } >+ >+ /** >+ * >+ * @return Topic namespace. >+ */ >+ public String getTopicNamespace() >+ { >+ return _topicNamespace; >+ } > } >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/topic/internal/ListSection.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.editor.capability/src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/topic/internal/ListSection.java,v >retrieving revision 1.7 >diff -u -r1.7 ListSection.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/topic/internal/ListSection.java 9 Jan 2007 19:51:44 -0000 1.7 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/topic/internal/ListSection.java 20 Jan 2007 13:33:42 -0000 >@@ -48,12 +48,12 @@ > import org.eclipse.tptp.wsdm.tooling.editor.ui.internal.AbstractPageSection; > import org.eclipse.tptp.wsdm.tooling.editor.ui.internal.IPageSection; > import org.eclipse.tptp.wsdm.tooling.editor.ui.internal.IUIPage; >+import org.eclipse.tptp.wsdm.tooling.model.capabilities.CapabilitiesFactory; > import org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability; > import org.eclipse.tptp.wsdm.tooling.model.capabilities.Topic; > import org.eclipse.tptp.wsdm.tooling.model.capabilities.TopicSpace; > import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.topic.internal.Messages; > import org.eclipse.tptp.wsdm.tooling.util.internal.EclipseUtils; >-import org.eclipse.tptp.wsdm.tooling.util.internal.TopicUtils; > 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; >@@ -70,392 +70,402 @@ > public class ListSection extends AbstractPageSection implements IViewerClient > { > >- private StructuredTreeViewer _topicViewer; >+ private StructuredTreeViewer _topicViewer; > >- private Button _newRootTopicButton; >+ private Button _newRootTopicButton; > >- private Button _newChildTopicButton; >+ private Button _newChildTopicButton; > >- private Button _removeButton; >+ private Button _removeButton; > >- private Label _errorLabel; >- >- private TopicContentProvider _contentProvider; >- >- private Topic _selectedTopic; >- >- private TopicSpace _selectedTopicSpace; >- >- private Composite _sectionClient; >- >- private Composite _buttonClient; >- >- /** >- * Creates a new object of this class. >- */ >- ListSection(CapabilityEditor editor, IUIPage page, ScrolledForm form, >- FormToolkit toolkit) >- { >- super(editor, page, form, toolkit); >- } >- >- /** >- * Creates the section. >- */ >- public void create() >- { >- _sectionClient = createSection(Messages.MNGMNT_EVENTS, >- Messages.MNSMNT_EVENTS_OF_CAP); >- GridLayout layout = new GridLayout(2, false); >- layout.marginWidth = LAYOUT_MARGIN_WIDTH; >- layout.verticalSpacing = LAYOUT_VERTICAL_SPACING; >- _sectionClient.setLayout(layout); >- FormToolkit toolkit = getToolkit(); >- >- _topicViewer = new StructuredTreeViewer(_sectionClient, toolkit, >- SWT.SINGLE, this); >- GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); >- gd.heightHint = 300; >- gd.widthHint = 50; >- _topicViewer.getControl().setLayoutData(gd); >- _topicViewer.getControl().setData(FormToolkit.KEY_DRAW_BORDER, >- FormToolkit.TREE_BORDER); >- >- // Set up a label provider that knows about the capability (so can >- // extract SemanticDecorations from it) >- _contentProvider = new TopicContentProvider(); >- _topicViewer.setContentProvider(_contentProvider); >- _topicViewer.setLabelProvider(_contentProvider >- .createLabelProvider(getForm().getShell())); >- _topicViewer.getControl().setSize(_topicViewer.getControl().computeSize(SWT.DEFAULT, SWT.DEFAULT)); >- >- _buttonClient = toolkit.createComposite(_sectionClient); >- layout = new GridLayout(); >- layout.marginHeight = 0; >- _buttonClient.setLayout(layout); >- gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_FILL, false, false); >- _buttonClient.setLayoutData(gd); >- >- _newRootTopicButton = createPushButton(_buttonClient, toolkit, >- Messages.ADD_ROOT_TOPIC, new Listener() >- { >- public void handleEvent(Event event) >- { >- addRootTopic(); >- } >- }); >- gd = new GridData(GridData.CENTER, SWT.NONE, false, false); >- _newRootTopicButton.setLayoutData(gd); >- gd.widthHint = 85; >- _newRootTopicButton.setEnabled(!_editor.isReadOnly()); >- >- _newChildTopicButton = createPushButton(_buttonClient, toolkit, >- Messages.ADD_CHILD_TOPIC, new Listener() >- { >- public void handleEvent(Event event) >- { >- addChildTopic(); >- } >- }); >- gd = new GridData(GridData.CENTER, SWT.NONE, false, false); >- gd.widthHint = 85; >- _newChildTopicButton.setLayoutData(gd); >- >- _removeButton = createPushButton(_buttonClient, toolkit, org.eclipse.tptp.wsdm.tooling.nls.messages.capability.internal.Messages.REMOVE_BUTTON_LABEL, >- new Listener() >- { >- public void handleEvent(Event event) >- { >- remove(); >- } >+ private Label _errorLabel; >+ >+ private TopicContentProvider _contentProvider; >+ >+ private Topic _selectedTopic; >+ >+ private TopicSpace _selectedTopicSpace; >+ >+ private Composite _sectionClient; >+ >+ private Composite _buttonClient; >+ >+ /** >+ * Creates a new object of this class. >+ */ >+ ListSection(CapabilityEditor editor, IUIPage page, ScrolledForm form, >+ FormToolkit toolkit) >+ { >+ super(editor, page, form, toolkit); >+ } >+ >+ /** >+ * Creates the section. >+ */ >+ public void create() >+ { >+ _sectionClient = createSection(Messages.MNGMNT_EVENTS, >+ Messages.MNSMNT_EVENTS_OF_CAP); >+ GridLayout layout = new GridLayout(2, false); >+ layout.marginWidth = LAYOUT_MARGIN_WIDTH; >+ layout.verticalSpacing = LAYOUT_VERTICAL_SPACING; >+ _sectionClient.setLayout(layout); >+ FormToolkit toolkit = getToolkit(); >+ >+ _topicViewer = new StructuredTreeViewer(_sectionClient, toolkit, >+ SWT.SINGLE, this); >+ GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); >+ gd.heightHint = 300; >+ gd.widthHint = 50; >+ _topicViewer.getControl().setLayoutData(gd); >+ _topicViewer.getControl().setData(FormToolkit.KEY_DRAW_BORDER, >+ FormToolkit.TREE_BORDER); >+ >+ // Set up a label provider that knows about the capability (so can >+ // extract SemanticDecorations from it) >+ _contentProvider = new TopicContentProvider(); >+ _topicViewer.setContentProvider(_contentProvider); >+ _topicViewer.setLabelProvider(_contentProvider >+ .createLabelProvider(getForm().getShell())); >+ _topicViewer.getControl() >+ .setSize( >+ _topicViewer.getControl().computeSize(SWT.DEFAULT, >+ SWT.DEFAULT)); >+ >+ _buttonClient = toolkit.createComposite(_sectionClient); >+ layout = new GridLayout(); >+ layout.marginHeight = 0; >+ _buttonClient.setLayout(layout); >+ gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, >+ GridData.VERTICAL_ALIGN_FILL, false, false); >+ _buttonClient.setLayoutData(gd); >+ >+ _newRootTopicButton = createPushButton(_buttonClient, toolkit, >+ Messages.ADD_ROOT_TOPIC, new Listener() { >+ public void handleEvent(Event event) >+ { >+ addRootTopic(); >+ } >+ }); >+ gd = new GridData(GridData.CENTER, SWT.NONE, false, false); >+ _newRootTopicButton.setLayoutData(gd); >+ gd.widthHint = 85; >+ _newRootTopicButton.setEnabled(!_editor.isReadOnly()); >+ >+ _newChildTopicButton = createPushButton(_buttonClient, toolkit, >+ Messages.ADD_CHILD_TOPIC, new Listener() { >+ public void handleEvent(Event event) >+ { >+ addChildTopic(); >+ } >+ }); >+ gd = new GridData(GridData.CENTER, SWT.NONE, false, false); >+ gd.widthHint = 85; >+ _newChildTopicButton.setLayoutData(gd); >+ >+ _removeButton = createPushButton( >+ _buttonClient, >+ toolkit, >+ org.eclipse.tptp.wsdm.tooling.nls.messages.capability.internal.Messages.REMOVE_BUTTON_LABEL, >+ new Listener() { >+ public void handleEvent(Event event) >+ { >+ remove(); >+ } >+ }); >+ gd = new GridData(GridData.CENTER, SWT.NONE, false, false); >+ gd.widthHint = 85; >+ _removeButton.setLayoutData(gd); >+ >+ _errorLabel = toolkit.createLabel(_sectionClient, ""); >+ gd = new GridData(GridData.FILL_HORIZONTAL); >+ gd.horizontalSpan = 2; >+ gd.grabExcessHorizontalSpace = true; >+ _errorLabel.setLayoutData(gd); >+ } >+ >+ private void addRootTopic() >+ { >+ String topicNamespace = null; >+ Capability capability = _editor.getCapabilityDomain().getCapability(); >+ if (_selectedTopicSpace == null) >+ { >+ topicNamespace = capability.getNamespace() + "/Topics"; >+ if (capability.getNamespace().endsWith("/")) >+ topicNamespace = capability.getNamespace() + "Topics"; >+ } >+ else >+ { >+ topicNamespace = _selectedTopicSpace.getNamespace(); >+ } >+ NewRootTopicDialog dlg = new NewRootTopicDialog(getForm().getShell(), >+ Messages.NEW_ROOT_TOPIC, topicNamespace); >+ int choice = dlg.open(); >+ if (choice == Window.OK) >+ { >+ Topic rootTopic = dlg.getRootTopic(); >+ String newTopicNamespace = dlg.getTopicNamespace(); >+ AddRootTopicCommand command = new AddRootTopicCommand(_editor >+ .getCapabilityDomain(), newTopicNamespace, rootTopic); >+ command.execute(); >+ _page.setDirty(); >+ } >+ } >+ >+ private void addChildTopic() >+ { >+ InputDialog dlg = new InputDialog(getForm().getShell(), >+ Messages.NEW_CHILD_TOPIC, Messages.TOPIC_NAME, >+ Messages.CHILD_TOPIC_LABEL, null); >+ int choice = dlg.open(); >+ if (choice == Window.OK) >+ { >+ Topic childTopic = CapabilitiesFactory.eINSTANCE.createTopic(); >+ childTopic.setName(dlg.getValue()); >+ AddChildTopicCommand command = new AddChildTopicCommand( >+ _selectedTopic, childTopic); >+ command.execute(); >+ _page.setDirty(); >+ } >+ } >+ >+ private void remove() >+ { >+ if (_selectedTopic != null) >+ { >+ RemoveTopicCommand command = new RemoveTopicCommand( >+ _selectedTopicSpace, _selectedTopic); >+ command.execute(); >+ } >+ else >+ { >+ RemoveTopicNamespaceCommand command = new RemoveTopicNamespaceCommand( >+ _editor.getCapabilityDomain(), _selectedTopicSpace); >+ command.execute(); >+ } >+ _page.setDirty(); >+ } >+ >+ /** >+ * Refreshes the section. >+ */ >+ public void refresh() >+ { >+ Capability model = _editor.getCapabilityDomain().getCapability(); >+ EList topicSpaceList = model.getTopicSpaces(); >+ _newChildTopicButton.setEnabled(false); >+ _removeButton.setEnabled(false); >+ if (topicSpaceList == null || topicSpaceList.size() == 0) >+ { >+ _topicViewer.setInput(null); >+ _page.enableSections(false); >+ return; >+ } >+ _topicViewer.setInput(topicSpaceList); >+ } >+ >+ public void handleDoubleClick() >+ { >+ // TODO Auto-generated method stub >+ } >+ >+ public void handleSelectionChanged(SelectionChangedEvent event) >+ { >+ Object[] objects = _topicViewer.getSelectedObjets(); >+ if (objects != null && objects.length != 0) >+ { >+ if (objects[0] instanceof TopicSpace) >+ { >+ _selectedTopicSpace = (TopicSpace) objects[0]; >+ _selectedTopic = null; >+ } >+ if (objects[0] instanceof Topic) >+ { >+ _selectedTopic = (Topic) objects[0]; >+ _selectedTopicSpace = getTopicSpace(_selectedTopic); >+ } >+ List sections = _page.getSections(); >+ _page.enableSections(true); >+ for (int i = 0; i < sections.size(); i++) >+ { >+ IPageSection section = (IPageSection) sections.get(i); >+ section.setSelectedObject(_selectedTopic); >+ section.selectionChanged(event); >+ } >+ return; >+ } >+ } >+ >+ /** >+ * Initializes control listeners. >+ */ >+ public void hookAllListeners() >+ { >+ getForm().addControlListener(new ControlAdapter() { >+ public void controlResized(ControlEvent e) >+ { >+ Rectangle formBounds = getForm().getClientArea(); >+ Rectangle sectionClientBounds = _sectionClient.getClientArea(); >+ Rectangle buttonCompositeBounds = _buttonClient.getClientArea(); >+ int width = sectionClientBounds.width >+ - buttonCompositeBounds.width - 20; >+ int height = Math.min(formBounds.height, >+ sectionClientBounds.height) - 100; >+ Tree tree = (Tree) _topicViewer.getControl(); >+ tree.setSize(width, height); >+ } > }); >- gd = new GridData(GridData.CENTER, SWT.NONE, false, false); >- gd.widthHint = 85; >- _removeButton.setLayoutData(gd); >- >- _errorLabel = toolkit.createLabel(_sectionClient, ""); >- gd = new GridData(GridData.FILL_HORIZONTAL); >- gd.horizontalSpan = 2; >- gd.grabExcessHorizontalSpace = true; >- _errorLabel.setLayoutData(gd); >- } >- >- private void addRootTopic() >- { >- String topicNamespace = null; >- Capability capability = _editor.getCapabilityDomain().getCapability(); >- if (_selectedTopicSpace == null) >- { >- topicNamespace = capability.getNamespace() + "/Topics"; >- if (capability.getNamespace().endsWith("/")) >- topicNamespace = capability.getNamespace() + "Topics"; >- } >- else >- { >- topicNamespace = _selectedTopicSpace.getNamespace(); >- } >- NewRootTopicDialog dlg = new NewRootTopicDialog(getForm().getShell(), >- Messages.NEW_ROOT_TOPIC, topicNamespace); >- int choice = dlg.open(); >- if (choice == Window.OK) >- { >- Topic rootTopic = dlg.getRootTopic(); >- String newTopicNamespace = dlg.getTopicNamespace(); >- AddRootTopicCommand command = new AddRootTopicCommand(_editor >- .getCapabilityDomain(), newTopicNamespace, rootTopic); >- command.execute(); >- _page.setDirty(); >- } >- } >- >- private void addChildTopic() >- { >- InputDialog dlg = new InputDialog(getForm().getShell(), >- Messages.NEW_CHILD_TOPIC, Messages.TOPIC_NAME, Messages.CHILD_TOPIC_LABEL, null); >- int choice = dlg.open(); >- if (choice == Window.OK) >- { >- Topic childTopic = TopicUtils.createNewTopic(); >- childTopic.setName(dlg.getValue()); >- AddChildTopicCommand command = new AddChildTopicCommand( >- _selectedTopic, childTopic); >- command.execute(); >- _page.setDirty(); >- } >- } >- >- private void remove() >- { >- if (_selectedTopic != null) >- { >- RemoveTopicCommand command = new RemoveTopicCommand( >- _selectedTopicSpace, _selectedTopic); >- command.execute(); >- } >- else >- { >- RemoveTopicNamespaceCommand command = new RemoveTopicNamespaceCommand( >- _editor.getCapabilityDomain(), _selectedTopicSpace); >- command.execute(); >- } >- _page.setDirty(); >- } >- >- /** >- * Refreshes the section. >- */ >- public void refresh() >- { >- Capability model = _editor.getCapabilityDomain().getCapability(); >- EList topicSpaceList = model.getTopicSpaces(); >- _newChildTopicButton.setEnabled(false); >- _removeButton.setEnabled(false); >- if (topicSpaceList == null || topicSpaceList.size() == 0) >- { >- _topicViewer.setInput(null); >- _page.enableSections(false); >- return; >- } >- _topicViewer.setInput(topicSpaceList); >- } >- >- public void handleDoubleClick() >- { >- // TODO Auto-generated method stub >- } >- >- public void handleSelectionChanged(SelectionChangedEvent event) >- { >- Object[] objects = _topicViewer.getSelectedObjets(); >- if (objects != null && objects.length != 0) >- { >- if (objects[0] instanceof TopicSpace) >- { >- _selectedTopicSpace = (TopicSpace) objects[0]; >- _selectedTopic = null; >- } >- if (objects[0] instanceof Topic) >- { >- _selectedTopic = (Topic) objects[0]; >- _selectedTopicSpace = getTopicSpace(_selectedTopic); >- } >- List sections = _page.getSections(); >- _page.enableSections(true); >- for (int i = 0; i < sections.size(); i++) >- { >- IPageSection section = (IPageSection) sections.get(i); >- section.setSelectedObject(_selectedTopic); >- section.selectionChanged(event); >- } >- return; >- } >- } >- >- /** >- * Initializes control listeners. >- */ >- public void hookAllListeners() >- { >- getForm().addControlListener(new ControlAdapter() { >- public void controlResized(ControlEvent e) { >- Rectangle formBounds = getForm().getClientArea(); >- Rectangle sectionClientBounds = _sectionClient.getClientArea(); >- Rectangle buttonCompositeBounds = _buttonClient.getClientArea(); >- int width = sectionClientBounds.width-buttonCompositeBounds.width-20; >- int height = Math.min(formBounds.height, sectionClientBounds.height)-100; >- Tree tree = (Tree) _topicViewer.getControl(); >- tree.setSize(width,height); >- } >- }); >- } >- >- /** >- * Handle viewer selection changed. >- */ >- public void selectionChanged(SelectionChangedEvent event) >- { >- _removeButton.setEnabled(!_editor.isReadOnly()); >- Object selectedObject = _topicViewer.getSelectedObjets()[0]; >- _newRootTopicButton.setEnabled(selectedObject instanceof TopicSpace && !_editor.isReadOnly()); >- _newChildTopicButton.setEnabled(selectedObject instanceof Topic && !_editor.isReadOnly()); >- } >- >- /** >- * Update its selected object. >- */ >- public void setSelectedObject(Object object) >- { >- } >- >- private TopicSpace getTopicSpace(Topic topic) >- { >- Object parent = _contentProvider.getParent(topic); >- while (!(parent instanceof TopicSpace)) >- parent = _contentProvider.getParent(parent); >- return (TopicSpace) parent; >- } >- >- /** >- * Enable or disable the section based on parameter passed. >- */ >- public void enable(boolean enabled) >- { >- // TODO Auto-generated method stub >- } >+ } >+ >+ /** >+ * Handle viewer selection changed. >+ */ >+ public void selectionChanged(SelectionChangedEvent event) >+ { >+ _removeButton.setEnabled(!_editor.isReadOnly()); >+ Object selectedObject = _topicViewer.getSelectedObjets()[0]; >+ _newRootTopicButton.setEnabled(selectedObject instanceof TopicSpace >+ && !_editor.isReadOnly()); >+ _newChildTopicButton.setEnabled(selectedObject instanceof Topic >+ && !_editor.isReadOnly()); >+ } >+ >+ /** >+ * Update its selected object. >+ */ >+ public void setSelectedObject(Object object) >+ { >+ } >+ >+ private TopicSpace getTopicSpace(Topic topic) >+ { >+ Object parent = _contentProvider.getParent(topic); >+ while (!(parent instanceof TopicSpace)) >+ parent = _contentProvider.getParent(parent); >+ return (TopicSpace) parent; >+ } >+ >+ /** >+ * Enable or disable the section based on parameter passed. >+ */ >+ public void enable(boolean enabled) >+ { >+ // TODO Auto-generated method stub >+ } > > } > > class TopicContentProvider implements ITreeContentProvider > { > >- private final Map _parentMap; >+ private final Map _parentMap; > >- TopicContentProvider() >- { >- _parentMap = new HashMap(); >- } >- >- public Object[] getChildren(Object parentElement) >- { >- if (parentElement instanceof Collection) >- { >- Collection c = (Collection) parentElement; >- return c.toArray(); >- } >- else if (parentElement instanceof TopicSpace) >- { >- TopicSpace topicSpace = (TopicSpace) parentElement; >- Object[] rootTopics = topicSpace.getRootTopics().toArray(); >- remember(parentElement, rootTopics); >- return rootTopics; >- } >- else if (parentElement instanceof Topic) >- { >- Topic topic = (Topic) parentElement; >- Object[] childrens = topic.getChildren().toArray(); >- remember(parentElement, childrens); >- return childrens; >- } >- return new Object[0]; >- } >- >- public Object getParent(Object element) >- { >- return _parentMap.get(element); >- } >- >- public boolean hasChildren(Object element) >- { >- return (getChildren(element).length > 0); >- } >- >- public Object[] getElements(Object inputElement) >- { >- return getChildren(inputElement); >- } >- >- public void dispose() >- { >- // TODO Auto-generated method stub >- } >- >- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) >- { >- // TODO Auto-generated method stub >- } >- >- private void remember(Object parent, Object[] childs) >- { >- for (int i = 0; i < childs.length; i++) >- { >- _parentMap.put(childs[i], parent); >- } >- } >- >- public ILabelProvider createLabelProvider(Shell shell) >- { >- return new TopicLabelProvider(shell); >- } >+ TopicContentProvider() >+ { >+ _parentMap = new HashMap(); >+ } >+ >+ public Object[] getChildren(Object parentElement) >+ { >+ if (parentElement instanceof Collection) >+ { >+ Collection c = (Collection) parentElement; >+ return c.toArray(); >+ } >+ else if (parentElement instanceof TopicSpace) >+ { >+ TopicSpace topicSpace = (TopicSpace) parentElement; >+ Object[] rootTopics = topicSpace.getRootTopics().toArray(); >+ remember(parentElement, rootTopics); >+ return rootTopics; >+ } >+ else if (parentElement instanceof Topic) >+ { >+ Topic topic = (Topic) parentElement; >+ Object[] childrens = topic.getChildren().toArray(); >+ remember(parentElement, childrens); >+ return childrens; >+ } >+ return new Object[0]; >+ } >+ >+ public Object getParent(Object element) >+ { >+ return _parentMap.get(element); >+ } >+ >+ public boolean hasChildren(Object element) >+ { >+ return (getChildren(element).length > 0); >+ } >+ >+ public Object[] getElements(Object inputElement) >+ { >+ return getChildren(inputElement); >+ } >+ >+ public void dispose() >+ { >+ // TODO Auto-generated method stub >+ } >+ >+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) >+ { >+ // TODO Auto-generated method stub >+ } >+ >+ private void remember(Object parent, Object[] childs) >+ { >+ for (int i = 0; i < childs.length; i++) >+ { >+ _parentMap.put(childs[i], parent); >+ } >+ } >+ >+ public ILabelProvider createLabelProvider(Shell shell) >+ { >+ return new TopicLabelProvider(shell); >+ } > > } > > class TopicLabelProvider extends LabelProvider implements ILabelProvider > { > >- private final static String TOPIC_KEY = "Topic"; >+ private final static String TOPIC_KEY = "Topic"; >+ >+ private ImageRegistry _imageRegistry; >+ >+ public TopicLabelProvider(Shell shell) >+ { >+ // We ignore the shell. It's here in the constructor in case we >+ // decide to use graphical icons on the tree later. > >- private ImageRegistry _imageRegistry; >+ _imageRegistry = new ImageRegistry(shell.getDisplay()); >+ Image imgProp = EclipseUtils.loadImage(shell.getDisplay(), >+ "icons/obj16/rootTopic_obj.gif"); >+ _imageRegistry.put(TOPIC_KEY, imgProp); >+ } > >- public TopicLabelProvider(Shell shell) >- { >- // We ignore the shell. It's here in the constructor in case we >- // decide to use graphical icons on the tree later. >- >- _imageRegistry = new ImageRegistry(shell.getDisplay()); >- Image imgProp = EclipseUtils.loadImage(shell.getDisplay(), >- "icons/obj16/rootTopic_obj.gif"); >- _imageRegistry.put(TOPIC_KEY, imgProp); >- } >- >- public String getText(Object element) >- { >- if (element instanceof TopicSpace) >- { >- TopicSpace topicSpace = (TopicSpace) element; >- return topicSpace.getNamespace(); >- } >- else if (element instanceof Topic) >- { >- Topic topic = (Topic) element; >- return topic.getName(); >- } >- return ""; >- } >- >- public Image getImage(Object element) >- { >- if (element instanceof Topic) >- return _imageRegistry.get(TOPIC_KEY); >- return null; >- } >+ public String getText(Object element) >+ { >+ if (element instanceof TopicSpace) >+ { >+ TopicSpace topicSpace = (TopicSpace) element; >+ return topicSpace.getNamespace(); >+ } >+ else if (element instanceof Topic) >+ { >+ Topic topic = (Topic) element; >+ return topic.getName(); >+ } >+ return ""; >+ } >+ >+ public Image getImage(Object element) >+ { >+ if (element instanceof Topic) >+ return _imageRegistry.get(TOPIC_KEY); >+ return null; >+ } > } >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/source/internal/XsdSourcePage.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.editor.capability/src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/source/internal/XsdSourcePage.java,v >retrieving revision 1.3 >diff -u -r1.3 XsdSourcePage.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/source/internal/XsdSourcePage.java 9 Jan 2007 19:51:45 -0000 1.3 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/source/internal/XsdSourcePage.java 20 Jan 2007 13:33:41 -0000 >@@ -12,100 +12,101 @@ > > package org.eclipse.tptp.wsdm.tooling.editor.capability.pages.source.internal; > >-import org.apache.muse.util.xml.XmlUtils; > import org.eclipse.swt.SWT; > import org.eclipse.swt.widgets.Composite; > import org.eclipse.swt.widgets.Control; > import org.eclipse.swt.widgets.Text; > import org.eclipse.tptp.wsdm.tooling.editor.capability.internal.CapabilityEditor; > import org.eclipse.tptp.wsdm.tooling.editor.ui.internal.AbstractSourcePage; >+import org.eclipse.tptp.wsdm.tooling.util.internal.CapUtils; > import org.eclipse.xsd.XSDSchema; > import org.w3c.dom.Document; > > /** > * Creates source page to display XSD Source.<br> > * <b>NOTE:</b> It is read-only. >- * >+ * > */ > > public class XsdSourcePage extends AbstractSourcePage > { > >- private Text _source; >+ private Text _source; > >- private Composite _parent; >+ private Composite _parent; > >- /** >- * Creates a new XSD source page. >- */ >- public XsdSourcePage(Composite parent, CapabilityEditor editor) >- { >- super(editor); >- _parent = parent; >- _display = editor.getEditorSite().getShell().getDisplay(); >- } >- >- /** >- * Creates the page. >- */ >- public void create() >- { >- _source = new Text(_parent, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL >- | SWT.READ_ONLY); >- XSDSchema propSchema = _editor.getCapabilityDomain().getPropertySchema(); >- Document doc = propSchema.getDocument(); >- String text = XmlUtils.toString(doc); >- setText(text); >- } >- >- /** >- * Initializes control listeners. >- */ >- public void hookAllListeners() >- { >- } >- >- /** >- * Refreshes the page. >- */ >- public void refresh() >- { >- // TODO Auto-generated method stub >- >- } >- >- /** >- * Handle propertyChanged event. >- */ >- public void propertyChanged(Object source, int propId) >- { >- // TODO Auto-generated method stub >- >- } >- >- /** >- * Returns the control associated with source. >- */ >- public Control getControl() >- { >- return _source; >- } >- >- /** >- * Set the text to source page. >- */ >- public void setText(String newText) >- { >- _source.setText(newText); >- } >- >- /** >- * >- * @return text of source page. >- */ >- public String getText() >- { >- return _source.getText(); >- } >+ /** >+ * Creates a new XSD source page. >+ */ >+ public XsdSourcePage(Composite parent, CapabilityEditor editor) >+ { >+ super(editor); >+ _parent = parent; >+ _display = editor.getEditorSite().getShell().getDisplay(); >+ } >+ >+ /** >+ * Creates the page. >+ */ >+ public void create() >+ { >+ _source = new Text(_parent, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL >+ | SWT.READ_ONLY); >+ XSDSchema propSchema = _editor.getCapabilityDomain() >+ .getPropertySchema(); >+ Document doc = propSchema.getDocument(); >+ String text = CapUtils.documentToString(doc); >+ setText(text); >+ } >+ >+ /** >+ * Initializes control listeners. >+ */ >+ public void hookAllListeners() >+ { >+ } >+ >+ /** >+ * Refreshes the page. >+ */ >+ public void refresh() >+ { >+ // TODO Auto-generated method stub >+ >+ } >+ >+ /** >+ * Handle propertyChanged event. >+ */ >+ public void propertyChanged(Object source, int propId) >+ { >+ // TODO Auto-generated method stub >+ >+ } >+ >+ /** >+ * Returns the control associated with source. >+ */ >+ public Control getControl() >+ { >+ return _source; >+ } >+ >+ /** >+ * Set the text to source page. >+ */ >+ public void setText(String newText) >+ { >+ _source.setText(newText); >+ } >+ >+ /** >+ * >+ * @return text of source page. >+ */ >+ public String getText() >+ { >+ return _source.getText(); >+ } > > } >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/source/internal/RmdSourcePage.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.editor.capability/src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/source/internal/RmdSourcePage.java,v >retrieving revision 1.5 >diff -u -r1.5 RmdSourcePage.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/source/internal/RmdSourcePage.java 9 Jan 2007 19:51:45 -0000 1.5 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/source/internal/RmdSourcePage.java 20 Jan 2007 13:33:41 -0000 >@@ -12,114 +12,104 @@ > > package org.eclipse.tptp.wsdm.tooling.editor.capability.pages.source.internal; > >-import java.io.InputStream; >- >-import org.eclipse.core.resources.IFile; > import org.eclipse.swt.SWT; > import org.eclipse.swt.widgets.Composite; > import org.eclipse.swt.widgets.Control; > import org.eclipse.swt.widgets.Text; > import org.eclipse.tptp.wsdm.tooling.editor.capability.internal.CapabilityEditor; > import org.eclipse.tptp.wsdm.tooling.editor.ui.internal.AbstractSourcePage; >-import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.internal.Messages; >-import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmToolingLog; > > /** > * Creates source page to display RMD Source.<br> > * <b>NOTE:</b> It is read-only. >- * >+ * > */ > > public class RmdSourcePage extends AbstractSourcePage > { > >- private Text _source; >+ private Text _source; >+ >+ private Composite _parent; >+ >+ /** >+ * Creates a new RMD source page. >+ */ >+ public RmdSourcePage(Composite parent, CapabilityEditor editor) >+ { >+ super(editor); >+ _parent = parent; >+ _display = editor.getEditorSite().getShell().getDisplay(); >+ } >+ >+ /** >+ * Creates the page. >+ */ >+ public void create() >+ { >+ _source = new Text(_parent, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL >+ | SWT.READ_ONLY); >+ >+ // TODO Set the text from RMD root >+ >+ /* >+ * IFile rmdFile = _editor.getCapabilityDomain().getMetaDataDescriptor() >+ * .getRMDFile(); try { InputStream is = rmdFile.getContents(); byte[] >+ * contents = new byte[is.available()]; is.read(contents); String text = >+ * new String(contents); setText(text); } catch (Exception e) { >+ * WsdmToolingLog.logError(Messages.FAILED_TO_READ_CONTENTS_OF_MCAP_ERROR_, >+ * e); } >+ */ >+ } >+ >+ /** >+ * Initializes control listeners. >+ */ >+ public void hookAllListeners() >+ { >+ } >+ >+ /** >+ * Refreshes the page. >+ */ >+ public void refresh() >+ { >+ // TODO Auto-generated method stub >+ >+ } > >- private Composite _parent; >+ /** >+ * Handle propertyChanged event. >+ */ >+ public void propertyChanged(Object source, int propId) >+ { >+ // TODO Auto-generated method stub > >- /** >- * Creates a new RMD source page. >- */ >- public RmdSourcePage(Composite parent, CapabilityEditor editor) >- { >- super(editor); >- _parent = parent; >- _display = editor.getEditorSite().getShell().getDisplay(); >- } >- >- /** >- * Creates the page. >- */ >- public void create() >- { >- _source = new Text(_parent, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL >- | SWT.READ_ONLY); >- >- // TODO Set the text from RMD root >- >- /*IFile rmdFile = _editor.getCapabilityDomain().getMetaDataDescriptor() >- .getRMDFile(); >- try >- { >- InputStream is = rmdFile.getContents(); >- byte[] contents = new byte[is.available()]; >- is.read(contents); >- String text = new String(contents); >- setText(text); >- } catch (Exception e) >- { >- WsdmToolingLog.logError(Messages.FAILED_TO_READ_CONTENTS_OF_MCAP_ERROR_, e); >- }*/ >- } >- >- /** >- * Initializes control listeners. >- */ >- public void hookAllListeners() >- { >- } >- >- /** >- * Refreshes the page. >- */ >- public void refresh() >- { >- // TODO Auto-generated method stub >- >- } >- >- /** >- * Handle propertyChanged event. >- */ >- public void propertyChanged(Object source, int propId) >- { >- // TODO Auto-generated method stub >- >- } >- >- /** >- * Returns the control associated with source. >- */ >- public Control getControl() >- { >- return _source; >- } >- >- /** >- * Set the text to source page. >- */ >- public void setText(String newText) >- { >- _source.setText(newText); >- } >- >- /** >- * >- * @return text of source page. >- */ >- public String getText() >- { >- return _source.getText(); >- } >+ } >+ >+ /** >+ * Returns the control associated with source. >+ */ >+ public Control getControl() >+ { >+ return _source; >+ } >+ >+ /** >+ * Set the text to source page. >+ */ >+ public void setText(String newText) >+ { >+ _source.setText(newText); >+ } >+ >+ /** >+ * >+ * @return text of source page. >+ */ >+ public String getText() >+ { >+ return _source.getText(); >+ } > > } >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.editor.capability/META-INF/MANIFEST.MF,v >retrieving revision 1.5 >diff -u -r1.5 MANIFEST.MF >--- META-INF/MANIFEST.MF 28 Sep 2006 15:52:59 -0000 1.5 >+++ META-INF/MANIFEST.MF 20 Jan 2007 13:33:30 -0000 >@@ -31,4 +31,3 @@ > org.eclipse.tptp.wsdm.tooling.viewers.internal, > org.eclipse.tptp.wsdm.tooling.wizard.capability.internal > Bundle-ClassPath: runtime/capability-editor.jar >-Import-Package: org.apache.xml.serialize >Index: src/org/eclipse/tptp/wsdm/tooling/wizard/capability/internal/NewCapabilityWizard.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.editor.capability/src/org/eclipse/tptp/wsdm/tooling/wizard/capability/internal/NewCapabilityWizard.java,v >retrieving revision 1.7 >diff -u -r1.7 NewCapabilityWizard.java >--- src/org/eclipse/tptp/wsdm/tooling/wizard/capability/internal/NewCapabilityWizard.java 9 Jan 2007 19:51:43 -0000 1.7 >+++ src/org/eclipse/tptp/wsdm/tooling/wizard/capability/internal/NewCapabilityWizard.java 20 Jan 2007 13:33:44 -0000 >@@ -15,7 +15,6 @@ > import java.io.ByteArrayInputStream; > import java.io.ByteArrayOutputStream; > import java.io.IOException; >-import java.io.StringWriter; > import java.lang.reflect.InvocationTargetException; > import java.util.HashMap; > import java.util.List; >@@ -23,9 +22,6 @@ > > import javax.xml.namespace.QName; > >-import org.apache.muse.util.xml.XmlUtils; >-import org.apache.xml.serialize.OutputFormat; >-import org.apache.xml.serialize.XMLSerializer; > import org.eclipse.core.resources.IContainer; > import org.eclipse.core.resources.IFile; > import org.eclipse.core.resources.IResource; >@@ -86,666 +82,713 @@ > * Wizard to create new capability. > */ > >-public class NewCapabilityWizard extends Wizard implements INewWizard { >+public class NewCapabilityWizard extends Wizard implements INewWizard >+{ > >- private NewCapabilityWizardPage _newCapPage; >+ private NewCapabilityWizardPage _newCapPage; > >- //private CapabilityFileWizardPage _capFilesPage; >+ // private CapabilityFileWizardPage _capFilesPage; > >- private CapabilityModelImporterPage _importerPage; >+ private CapabilityModelImporterPage _importerPage; > >- private ISelection _selection; >- >- private Definition _wsdlCapDefinition; >- >- private Map _options = new HashMap(); >- >- private IFile _capFile; >- >- private boolean canContinue = true; >- >- private boolean isOverwriteXSD = true; >- >- private final static String DEFAULT_DESCRIPTION = "Example capability"; >- >- /** >- * Creates new object of this class. >- */ >- public NewCapabilityWizard() { >- super(); >- setNeedsProgressMonitor(true); >- } >- >- /** >- * Adding the page to the wizard. >- */ >- >- public void addPages() { >- _newCapPage = new NewCapabilityWizardPage(_selection, this); >- addPage(_newCapPage); >- >- //_capFilesPage = new CapabilityFileWizardPage(_selection, this); >- //addPage(_capFilesPage); >- >- _importerPage = new CapabilityModelImporterPage(_selection, this); >- addPage(_importerPage); >- } >- >- /** >- * Creats a new capability. >- */ >- public boolean performFinish() { >- String containerName = _newCapPage.getContainerName(); >- String capQName = _newCapPage.getPrefix() + ":" >- + _newCapPage.getCapabilityName(); >- String capabilityName = CapUtils.getCapabilityNameFromQName(capQName); >- String capPrefix = CapUtils.getCapabilityPrefixFromQName(capQName); >- if (capPrefix == null) >- 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"; >- >- String capNamespace = capNS; >- String xsdNS = capNS; >- String rmdNS = capNS + "metadata"; >- >- String capFilePath = null; >- if (!containerName.endsWith("/")) { >- capFilePath = containerName + "/" + targetCapFileName; >- } else { >- capFilePath = containerName + targetCapFileName; >- } >- >- XSDSchema[] importedXsd = _importerPage.getSchemaToImport(); >- Definition[] importedWsdl = _importerPage.getWsdlToImport(); >- >- _options.put(CapabilityWizardKeys.CONTAINER_NAME_KEY, containerName); >- _options.put(CapabilityWizardKeys.CAP_NS_KEY, capNamespace); >- _options.put(CapabilityWizardKeys.CAP_PREFIX_KEY, capPrefix); >- _options.put(CapabilityWizardKeys.CAP_NAME_KEY, capabilityName); >- _options.put(CapabilityWizardKeys.CAP_FILE_NAME_KEY, targetCapFileName); >- _options.put(CapabilityWizardKeys.CAP_FILE_PATH_KEY, capFilePath); >- >- _options.put(CapabilityWizardKeys.XSD_FILE_PATH_KEY, xsdFilePath); >- _options.put(CapabilityWizardKeys.XSD_FILE_NAME_KEY, xsdFileName); >- _options.put(CapabilityWizardKeys.XSD_NS_KEY, xsdNS); >- >- _options.put(CapabilityWizardKeys.RMD_FILE_PATH_KEY, rmdFilePath); >- _options.put(CapabilityWizardKeys.RMD_FILE_NAME_KEY, rmdFileName); >- _options.put(CapabilityWizardKeys.RMD_NS_KEY, rmdNS); >- >- _options.put(CapabilityWizardKeys.IMPORT_XSD_KEY, importedXsd); >- _options.put(CapabilityWizardKeys.IMPORT_WSDL_KEY, importedWsdl); >- >- IRunnableWithProgress shouldOverwriteOperation = new IRunnableWithProgress() >- { >- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException >- { >- shouldOverWriteXSD(); >- } >- }; >- try >- { >- getContainer().run(false, false, shouldOverwriteOperation); >- } catch (InvocationTargetException e1) >- { >- WsdmToolingLog >- .logError(Messages.FAILED_CREATE_CAP_ERROR_ + " ", >- e1); >- } catch (InterruptedException e1) >- { >- WsdmToolingLog >- .logError(Messages.FAILED_CREATE_CAP_ERROR_ + " ", >- e1); >- } >- >- IRunnableWithProgress op = new IRunnableWithProgress() { >- public void run(IProgressMonitor monitor) >- throws InvocationTargetException { >- try { >- doFinish(monitor); >- } catch (CoreException e) { >- WsdmToolingLog >- .logError(Messages.FAILED_CREATE_CAP_ERROR_ + " ", >- e); >- } catch (IOException e) { >- WsdmToolingLog >- .logError(Messages.FAILED_CREATE_CAP_ERROR_ + " ", >- e); >- } catch (InterruptedException e) >- { >- e.printStackTrace(); >- } finally { >- monitor.done(); >- } >- } >- }; >- >- if(canContinue) >- { >- try { >- getContainer().run(true, false, op); >- } catch (InterruptedException e) { >- WsdmToolingLog.logError(Messages.FAILED_CREATE_CAP_ERROR_ + " ", e); >- return false; >- } catch (InvocationTargetException e) { >- Throwable realException = e.getTargetException(); >- MessageDialog.openError(getShell(), "Error", realException >- .getMessage()); >- return false; >- } >- } >- return true; >- } >- >- private void doFinish(IProgressMonitor monitor) throws CoreException, >- IOException, InvocationTargetException, InterruptedException { >- verifyContainer(); >- if(isOverwriteXSD) >- doFinishXSD(monitor); >- doFinishRMD(monitor); >- doFinishCapFile(monitor); >- refreshContainer(monitor); >- openFile(monitor); >- } >- >- private void verifyContainer() { >- // TODO Put the code to verify container >- } >- >- private void shouldOverWriteXSD() >- { >- XSDSchema[] importedXsd = (XSDSchema[]) _options >- .get(CapabilityWizardKeys.IMPORT_XSD_KEY); >- String xsdFilePath = (String) _options.get(CapabilityWizardKeys.XSD_FILE_PATH_KEY); >- if(importedXsd.length != 0) >- { >- for(int i=0;i<importedXsd.length;i++) >- { >- IFile importedXsdFile = null; >+ private ISelection _selection; >+ >+ private Definition _wsdlCapDefinition; >+ >+ private Map _options = new HashMap(); >+ >+ private IFile _capFile; >+ >+ private boolean canContinue = true; >+ >+ private boolean isOverwriteXSD = true; >+ >+ private final static String DEFAULT_DESCRIPTION = "Example capability"; >+ >+ /** >+ * Creates new object of this class. >+ */ >+ public NewCapabilityWizard() >+ { >+ super(); >+ setNeedsProgressMonitor(true); >+ } >+ >+ /** >+ * Adding the page to the wizard. >+ */ >+ >+ public void addPages() >+ { >+ _newCapPage = new NewCapabilityWizardPage(_selection, this); >+ addPage(_newCapPage); >+ >+ // _capFilesPage = new CapabilityFileWizardPage(_selection, this); >+ // addPage(_capFilesPage); >+ >+ _importerPage = new CapabilityModelImporterPage(_selection, this); >+ addPage(_importerPage); >+ } >+ >+ /** >+ * Creats a new capability. >+ */ >+ public boolean performFinish() >+ { >+ String containerName = _newCapPage.getContainerName(); >+ String capQName = _newCapPage.getPrefix() + ":" >+ + _newCapPage.getCapabilityName(); >+ String capabilityName = CapUtils.getCapabilityNameFromQName(capQName); >+ String capPrefix = CapUtils.getCapabilityPrefixFromQName(capQName); >+ if (capPrefix == null) >+ 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"; >+ >+ String capNamespace = capNS; >+ String xsdNS = capNS; >+ String rmdNS = capNS + "metadata"; >+ >+ String capFilePath = null; >+ if (!containerName.endsWith("/")) >+ { >+ capFilePath = containerName + "/" + targetCapFileName; >+ } >+ else >+ { >+ capFilePath = containerName + targetCapFileName; >+ } >+ >+ XSDSchema[] importedXsd = _importerPage.getSchemaToImport(); >+ Definition[] importedWsdl = _importerPage.getWsdlToImport(); >+ >+ _options.put(CapabilityWizardKeys.CONTAINER_NAME_KEY, containerName); >+ _options.put(CapabilityWizardKeys.CAP_NS_KEY, capNamespace); >+ _options.put(CapabilityWizardKeys.CAP_PREFIX_KEY, capPrefix); >+ _options.put(CapabilityWizardKeys.CAP_NAME_KEY, capabilityName); >+ _options.put(CapabilityWizardKeys.CAP_FILE_NAME_KEY, targetCapFileName); >+ _options.put(CapabilityWizardKeys.CAP_FILE_PATH_KEY, capFilePath); >+ >+ _options.put(CapabilityWizardKeys.XSD_FILE_PATH_KEY, xsdFilePath); >+ _options.put(CapabilityWizardKeys.XSD_FILE_NAME_KEY, xsdFileName); >+ _options.put(CapabilityWizardKeys.XSD_NS_KEY, xsdNS); >+ >+ _options.put(CapabilityWizardKeys.RMD_FILE_PATH_KEY, rmdFilePath); >+ _options.put(CapabilityWizardKeys.RMD_FILE_NAME_KEY, rmdFileName); >+ _options.put(CapabilityWizardKeys.RMD_NS_KEY, rmdNS); >+ >+ _options.put(CapabilityWizardKeys.IMPORT_XSD_KEY, importedXsd); >+ _options.put(CapabilityWizardKeys.IMPORT_WSDL_KEY, importedWsdl); >+ >+ IRunnableWithProgress shouldOverwriteOperation = new IRunnableWithProgress() { >+ public void run(IProgressMonitor monitor) >+ throws InvocationTargetException, InterruptedException >+ { >+ shouldOverWriteXSD(); >+ } >+ }; >+ try >+ { >+ getContainer().run(false, false, shouldOverwriteOperation); >+ } catch (InvocationTargetException e1) >+ { >+ WsdmToolingLog >+ .logError(Messages.FAILED_CREATE_CAP_ERROR_ + " ", e1); >+ } catch (InterruptedException e1) >+ { >+ WsdmToolingLog >+ .logError(Messages.FAILED_CREATE_CAP_ERROR_ + " ", e1); >+ } >+ >+ IRunnableWithProgress op = new IRunnableWithProgress() { >+ public void run(IProgressMonitor monitor) >+ throws InvocationTargetException >+ { >+ try >+ { >+ doFinish(monitor); >+ } catch (CoreException e) >+ { >+ WsdmToolingLog.logError(Messages.FAILED_CREATE_CAP_ERROR_ >+ + " ", e); >+ } catch (IOException e) >+ { >+ WsdmToolingLog.logError(Messages.FAILED_CREATE_CAP_ERROR_ >+ + " ", e); >+ } catch (InterruptedException e) >+ { >+ e.printStackTrace(); >+ } finally >+ { >+ monitor.done(); >+ } >+ } >+ }; >+ >+ if (canContinue) >+ { >+ try >+ { >+ getContainer().run(true, false, op); >+ } catch (InterruptedException e) >+ { >+ WsdmToolingLog.logError( >+ Messages.FAILED_CREATE_CAP_ERROR_ + " ", e); >+ return false; >+ } catch (InvocationTargetException e) >+ { >+ Throwable realException = e.getTargetException(); >+ MessageDialog.openError(getShell(), "Error", realException >+ .getMessage()); >+ return false; >+ } >+ } >+ return true; >+ } >+ >+ private void doFinish(IProgressMonitor monitor) throws CoreException, >+ IOException, InvocationTargetException, InterruptedException >+ { >+ verifyContainer(); >+ if (isOverwriteXSD) >+ doFinishXSD(monitor); >+ doFinishRMD(monitor); >+ doFinishCapFile(monitor); >+ refreshContainer(monitor); >+ openFile(monitor); >+ } >+ >+ private void verifyContainer() >+ { >+ // TODO Put the code to verify container >+ } >+ >+ private void shouldOverWriteXSD() >+ { >+ XSDSchema[] importedXsd = (XSDSchema[]) _options >+ .get(CapabilityWizardKeys.IMPORT_XSD_KEY); >+ String xsdFilePath = (String) _options >+ .get(CapabilityWizardKeys.XSD_FILE_PATH_KEY); >+ if (importedXsd.length != 0) >+ { >+ for (int i = 0; i < importedXsd.length; i++) >+ { >+ IFile importedXsdFile = null; >+ try >+ { >+ importedXsdFile = EclipseUtils.getIFile(importedXsd[i] >+ .eResource().getURI().toString()); >+ } catch (CoreException e) >+ { >+ WsdmToolingLog.logError(e.getLocalizedMessage(), e); >+ } >+ if (importedXsdFile.exists() >+ && importedXsdFile.getFullPath().toString().equals( >+ xsdFilePath)) >+ { >+ isOverwriteXSD = false; >+ canContinue = true; >+ return; >+ } >+ } >+ } >+ >+ IFile xsdFile = null; > try > { >- importedXsdFile = EclipseUtils.getIFile(importedXsd[i].eResource().getURI().toString()); >+ xsdFile = EclipseUtils.getIFile(xsdFilePath); > } catch (CoreException e) > { >- WsdmToolingLog.logError(e.getLocalizedMessage(), e); >+ WsdmToolingLog.logError(e.getLocalizedMessage(), e); > } >- if(importedXsdFile.exists() && importedXsdFile.getFullPath().toString().equals(xsdFilePath)) >+ if (xsdFile.exists()) >+ { >+ isOverwriteXSD = MessageDialog >+ .openConfirm(getShell(), Messages.CONFIRM_MESSAGE, Messages >+ .bind(Messages.OVERWRITE_FILE_MESSAGE, xsdFile >+ .getName())); >+ canContinue = isOverwriteXSD; >+ } >+ } >+ >+ private void refreshContainer(IProgressMonitor monitor) >+ throws CoreException >+ { >+ String containerName = (String) _options >+ .get(CapabilityWizardKeys.CONTAINER_NAME_KEY); >+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); >+ IResource resource = root.findMember(new Path(containerName)); >+ if (!resource.exists() || !(resource instanceof IContainer)) >+ { >+ throwCoreException(Messages.bind( >+ Messages.CONTAINER_DOES_NOT_EXISTS_ERROR_, containerName)); >+ } >+ IContainer container = (IContainer) resource; >+ container.refreshLocal(IResource.DEPTH_ONE, monitor); >+ } >+ >+ private void throwCoreException(String message) throws CoreException >+ { >+ IStatus status = new Status(IStatus.ERROR, "MrEditor2", IStatus.OK, >+ message, null); >+ throw new CoreException(status); >+ } >+ >+ private void doFinishXSD(IProgressMonitor monitor) throws CoreException >+ { >+ String xsdFilePath = (String) _options >+ .get(CapabilityWizardKeys.XSD_FILE_PATH_KEY); >+ IFile xsdFile = EclipseUtils.getIFile(xsdFilePath); >+ monitor.beginTask(Messages.CREATE_XSD_FILE, IProgressMonitor.UNKNOWN); >+ createXSDFile(xsdFile, monitor); >+ xsdFile.refreshLocal(IResource.DEPTH_ONE, monitor); >+ } >+ >+ private void doFinishRMD(IProgressMonitor monitor) throws CoreException >+ { >+ String rmdFilePath = (String) _options >+ .get(CapabilityWizardKeys.RMD_FILE_PATH_KEY); >+ IFile rmdFile = EclipseUtils.getIFile(rmdFilePath); >+ monitor.beginTask(Messages.CREATE_RMD_FILE, IProgressMonitor.UNKNOWN); >+ createRMDFile(rmdFile, monitor); >+ rmdFile.refreshLocal(IResource.DEPTH_ONE, monitor); >+ } >+ >+ private void doFinishCapFile(IProgressMonitor monitor) throws CoreException >+ { >+ String capFilePath = (String) _options >+ .get(CapabilityWizardKeys.CAP_FILE_PATH_KEY); >+ _capFile = EclipseUtils.getIFile(capFilePath); >+ monitor.beginTask(Messages.CREATE_MCAP_FILE, IProgressMonitor.UNKNOWN); >+ createCapabilityFile(_capFile, monitor); >+ _capFile.refreshLocal(IResource.DEPTH_ONE, monitor); >+ } >+ >+ private void openFile(IProgressMonitor monitor) >+ { >+ monitor.beginTask(Messages.OPEN_FILE, IProgressMonitor.UNKNOWN); >+ getShell().getDisplay().asyncExec(new Runnable() { >+ public void run() >+ { >+ IWorkbenchPage pg = PlatformUI.getWorkbench() >+ .getActiveWorkbenchWindow().getActivePage(); >+ try >+ { >+ IDE.openEditor(pg, _capFile, CapabilityEditor.ID); >+ } catch (PartInitException e) >+ { >+ WsdmToolingLog.logError(Messages.FAILED_TO_OPEN_FILE_ERROR_ >+ + " ", e); >+ } >+ } >+ }); >+ } >+ >+ private void createXSDFile(IFile schemaFile, IProgressMonitor monitor) >+ { >+ String xsdNamespace = (String) _options >+ .get(CapabilityWizardKeys.XSD_NS_KEY); >+ XSDSchema schema = XsdUtils.createNewXSDSchema(xsdNamespace); >+ String xsdURI = schemaFile.getFullPath().toString(); >+ XsdUtils.saveXSDSchema(schema, xsdURI, null, true); >+ } >+ >+ private void createRMDFile(IFile rmdFile, IProgressMonitor monitor) >+ { >+ String capName = (String) _options >+ .get(CapabilityWizardKeys.CAP_NAME_KEY); >+ String capNS = (String) _options.get(CapabilityWizardKeys.CAP_NS_KEY); >+ String descriptorName = capName + "Descriptor"; >+ String capabilityPortTypeName = capName + "PortType"; >+ String capabilityFileName = (String) _options >+ .get(CapabilityWizardKeys.CAP_FILE_NAME_KEY); >+ DocumentRoot documentRoot = MetaDataUtils.createNewMetadataRoot(capNS, >+ descriptorName, capabilityPortTypeName, capabilityFileName); >+ MetaDataUtils.serializeAndFormat(documentRoot, rmdFile, monitor); >+ } >+ >+ private void createCapabilityFile(IFile capabilityFile, >+ IProgressMonitor monitor) >+ { >+ String location = capabilityFile.getLocation().toString(); >+ String capNS = (String) _options.get(CapabilityWizardKeys.CAP_NS_KEY); >+ String capPrefix = (String) _options >+ .get(CapabilityWizardKeys.CAP_PREFIX_KEY); >+ String capName = (String) _options >+ .get(CapabilityWizardKeys.CAP_NAME_KEY); >+ _wsdlCapDefinition = WsdlUtils.createNewWSDLDefinition(capNS, >+ capPrefix, capName, location); >+ >+ _wsdlCapDefinition.addNamespace("wsrmd", WsdmConstants.WSRMD_NS); >+ _wsdlCapDefinition.addNamespace("wsrp", WsdmConstants.WSRP_NS); >+ >+ createWSDLTypes(); >+ createWSDLPortType(); >+ >+ String wsdlURI = capabilityFile.getFullPath().toString(); >+ ByteArrayOutputStream baos = null; >+ try >+ { >+ baos = WsdlUtils.saveWSDLDefinition(_wsdlCapDefinition, wsdlURI, >+ null); >+ } catch (IOException e) > { >- isOverwriteXSD = false; >- canContinue = true; >- return; >- } >- } >- } >- >- IFile xsdFile = null; >- try >- { >- xsdFile = EclipseUtils.getIFile(xsdFilePath); >- } catch (CoreException e) >- { >- WsdmToolingLog.logError(e.getLocalizedMessage(), e); >- } >- if(xsdFile.exists()) >- { >- isOverwriteXSD = MessageDialog.openConfirm(getShell(), Messages.CONFIRM_MESSAGE, Messages.bind(Messages.OVERWRITE_FILE_MESSAGE, xsdFile.getName())); >- canContinue = isOverwriteXSD; >- } >- } >- >- private void refreshContainer(IProgressMonitor monitor) >- throws CoreException { >- String containerName = (String) _options >- .get(CapabilityWizardKeys.CONTAINER_NAME_KEY); >- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); >- IResource resource = root.findMember(new Path(containerName)); >- if (!resource.exists() || !(resource instanceof IContainer)) { >- throwCoreException(Messages.bind(Messages.CONTAINER_DOES_NOT_EXISTS_ERROR_, containerName)); >- } >- IContainer container = (IContainer) resource; >- container.refreshLocal(IResource.DEPTH_ONE, monitor); >- } >- >- private void throwCoreException(String message) throws CoreException { >- IStatus status = new Status(IStatus.ERROR, "MrEditor2", IStatus.OK, >- message, null); >- throw new CoreException(status); >- } >- >- private void doFinishXSD(IProgressMonitor monitor) throws CoreException { >- String xsdFilePath = (String) _options >- .get(CapabilityWizardKeys.XSD_FILE_PATH_KEY); >- IFile xsdFile = EclipseUtils.getIFile(xsdFilePath); >- monitor.beginTask(Messages.CREATE_XSD_FILE, IProgressMonitor.UNKNOWN); >- createXSDFile(xsdFile, monitor); >- xsdFile.refreshLocal(IResource.DEPTH_ONE, monitor); >- } >- >- private void doFinishRMD(IProgressMonitor monitor) throws CoreException { >- String rmdFilePath = (String) _options >- .get(CapabilityWizardKeys.RMD_FILE_PATH_KEY); >- IFile rmdFile = EclipseUtils.getIFile(rmdFilePath); >- monitor.beginTask(Messages.CREATE_RMD_FILE, IProgressMonitor.UNKNOWN); >- createRMDFile(rmdFile, monitor); >- rmdFile.refreshLocal(IResource.DEPTH_ONE, monitor); >- } >- >- private void doFinishCapFile(IProgressMonitor monitor) throws CoreException { >- String capFilePath = (String) _options >- .get(CapabilityWizardKeys.CAP_FILE_PATH_KEY); >- _capFile = EclipseUtils.getIFile(capFilePath); >- monitor.beginTask(Messages.CREATE_MCAP_FILE, IProgressMonitor.UNKNOWN); >- createCapabilityFile(_capFile, monitor); >- _capFile.refreshLocal(IResource.DEPTH_ONE, monitor); >- } >- >- private void openFile(IProgressMonitor monitor) { >- monitor.beginTask(Messages.OPEN_FILE, IProgressMonitor.UNKNOWN); >- getShell().getDisplay().asyncExec(new Runnable() { >- public void run() { >- IWorkbenchPage pg = PlatformUI.getWorkbench() >- .getActiveWorkbenchWindow().getActivePage(); >- try { >- IDE.openEditor(pg, _capFile, CapabilityEditor.ID); >- } catch (PartInitException e) { >- WsdmToolingLog.logError(Messages.FAILED_TO_OPEN_FILE_ERROR_ + " ", >- e); >- } >- } >- }); >- } >- >- private void createXSDFile(IFile schemaFile, IProgressMonitor monitor) { >- String xsdNamespace = (String) _options >- .get(CapabilityWizardKeys.XSD_NS_KEY); >- XSDSchema schema = XsdUtils.createNewXSDSchema(xsdNamespace); >- String xsdURI = schemaFile.getFullPath().toString(); >- XsdUtils.saveXSDSchema(schema, xsdURI, null, true); >- } >- >- private void createRMDFile(IFile rmdFile, IProgressMonitor monitor) { >- String capName = (String) _options >- .get(CapabilityWizardKeys.CAP_NAME_KEY); >- String capNS = (String) _options.get(CapabilityWizardKeys.CAP_NS_KEY); >- String descriptorName = capName + "Descriptor"; >- DocumentRoot documentRoot = MetaDataUtils.createNewMetadataRoot(capNS, >- descriptorName); >- MetaDataUtils.serializeAndFormat(documentRoot, rmdFile, monitor); >- } >- >- private void createCapabilityFile(IFile capabilityFile, >- IProgressMonitor monitor) { >- String location = capabilityFile.getLocation().toString(); >- String capNS = (String) _options.get(CapabilityWizardKeys.CAP_NS_KEY); >- String capPrefix = (String) _options >- .get(CapabilityWizardKeys.CAP_PREFIX_KEY); >- String capName = (String) _options >- .get(CapabilityWizardKeys.CAP_NAME_KEY); >- _wsdlCapDefinition = WsdlUtils.createNewWSDLDefinition(capNS, >- capPrefix, capName, location); >- >- _wsdlCapDefinition.addNamespace("wsrmd", WsdmConstants.WSRMD_NS); >- _wsdlCapDefinition.addNamespace("wsrp", WsdmConstants.WSRP_NS); >- >- createWSDLTypes(); >- createWSDLPortType(); >- >- String wsdlURI = capabilityFile.getFullPath().toString(); >- ByteArrayOutputStream baos = null; >- try >- { >- baos = WsdlUtils.saveWSDLDefinition( >- _wsdlCapDefinition, wsdlURI, null); >- } catch (IOException e) >- { >- WsdmToolingLog.logError(Messages.FAILED_CREATE_CAP_ERROR_ + " ", e); >- } >- >- String afterEdit = wsdlEdit(baos.toString()); >- ByteArrayInputStream baInputStream = new ByteArrayInputStream(afterEdit >- .getBytes()); >- >- try { >- if (capabilityFile.exists()) { >- capabilityFile.delete(true, null); >- } >- capabilityFile.create(baInputStream, true, null); >- } catch (CoreException ce) { >- WsdmToolingLog.logError(Messages.FAILED_CREATE_CAP_ERROR_ + " ", ce); >- } >- } >- >- private void createWSDLTypes() { >- Types types = WSDLFactory.eINSTANCE.createTypes(); >- types.setEnclosingDefinition(_wsdlCapDefinition); >- _wsdlCapDefinition.setETypes(types); >- createResourcePropertiesSchema(); >- } >- >- private void createResourcePropertiesSchema() { >- >- String capNS = (String) _options.get(CapabilityWizardKeys.CAP_NS_KEY); >- XSDSchema schema = WsdlUtils.createOrFindSchema(_wsdlCapDefinition, >- capNS); >- createAnnotation(schema); >- if(isOverwriteXSD) >- createPropXSDInclude(schema); >- createResourceProperties(schema); >- } >- >- private void createResourceProperties(XSDSchema schema) { >- String capName = (String) _options >- .get(CapabilityWizardKeys.CAP_NAME_KEY); >- XSDElementDeclaration resourcePropertyElement = XSDFactory.eINSTANCE >- .createXSDElementDeclaration(); >- resourcePropertyElement.setName(capName + "Properties"); >- resourcePropertyElement.setTypeDefinition(null); >- schema.getContents().add(resourcePropertyElement); >- >- XSDSchema[] importedXsd = (XSDSchema[]) _options >- .get(CapabilityWizardKeys.IMPORT_XSD_KEY); >- for (int i = 0; i < importedXsd.length; i++) { >- importXSD(resourcePropertyElement, importedXsd[i]); >- } >- } >- >- private void importXSD(XSDElementDeclaration resourcePropertyElement, >- XSDSchema schema) { >- // Get the location for XSD Schema in drive fromat >- String schemaLocation = XsdUtils.getLocalSystemSchemaLocation(schema); >- >- // Get the location for capability file >- String capFileLocation = _capFile.getLocation().toString(); >- >- // Create xsd:import element >- String importSchemaLocation = EclipseUtils.getRelativePath( >- capFileLocation, schemaLocation, '/'); >- XsdUtils.createImportStatement(resourcePropertyElement.getSchema(), >- schema.getTargetNamespace(), importSchemaLocation); >- >- // Prepare resource property element >- 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); >- } >- >- List elements = schema.getElementDeclarations(); >- for (int i = 0; i < elements.size(); i++) { >- // Add element to resource properties >- XSDElementDeclaration element = (XSDElementDeclaration) elements >- .get(i); >- >- XSDElementDeclaration propertyRef = XSDFactory.eINSTANCE >- .createXSDElementDeclaration(); >- propertyRef.setResolvedElementDeclaration(element); >- XSDParticle simpleElementParticle = XSDFactory.eINSTANCE >- .createXSDParticle(); >- simpleElementParticle.setContent(propertyRef); >- modelGroup.getContents().add(simpleElementParticle); >- } >- } >- >- private void createAnnotation(XSDSchema schema) { >- XSDAnnotation annotation = XSDFactory.eINSTANCE.createXSDAnnotation(); >- schema.getContents().add(annotation); >- Element documentation = annotation.createUserInformation(null); >- annotation.getElement().appendChild(documentation); >- documentation.appendChild(documentation.getOwnerDocument() >- .createTextNode(DEFAULT_DESCRIPTION)); >- } >- >- private void createPropXSDInclude(XSDSchema schema) { >- String xsdFileName = (String) _options >- .get(CapabilityWizardKeys.XSD_FILE_NAME_KEY); >- XSDInclude include = XSDFactory.eINSTANCE.createXSDInclude(); >- include.setSchemaLocation(xsdFileName); >- schema.getContents().add(include); >- } >- >- private void createWSDLPortType() { >- PortType pt = WSDLFactory.eINSTANCE.createPortType(); >- String capNS = (String) _options.get(CapabilityWizardKeys.CAP_NS_KEY); >- String capName = (String) _options >- .get(CapabilityWizardKeys.CAP_NAME_KEY); >- pt.setQName(new QName(capNS, capName + "PortType")); >- pt.setEnclosingDefinition(_wsdlCapDefinition); >- _wsdlCapDefinition.addPortType(pt); >- >- Definition[] importedWSDL = (Definition[]) _options >- .get(CapabilityWizardKeys.IMPORT_WSDL_KEY); >- for (int i = 0; i < importedWSDL.length; i++) { >- importWSDL(pt, importedWSDL[i]); >- } >- } >- >- private void importWSDL(PortType pt, Definition importedWSDL) { >- importWSDLImports(pt, importedWSDL); >- >- // Get the location for imported WSDL >- String importedWsdlLocation; >- try >- { >- importedWsdlLocation = WsdlUtils >- .getLocalSystemWSDLLocation(importedWSDL); >- } catch (CoreException e) >- { >- return; >- } >- >- // Get the location for capability file >- String capFileLocation = _capFile.getLocation().toString(); >- >- // Create wsdl:import statement >- String relativePath = EclipseUtils.getRelativePath(capFileLocation, >- importedWsdlLocation, '/'); >- WsdlUtils.createWSDLImport(pt.getEnclosingDefinition(), importedWSDL >- .getTargetNamespace(), relativePath); >- >- PortType importPortType = WsdlUtils.getPortType(importedWSDL); >- if (importPortType == null) >- return; >- List opList = importPortType.getEOperations(); >- for (int i = 0; i < opList.size(); i++) { >- Operation importOp = (Operation) opList.get(i); >- Operation newOperation = WSDLFactory.eINSTANCE.createOperation(); >- pt.addOperation(newOperation); >- if(!importOperation(newOperation, importOp)) >- pt.getEOperations().remove(newOperation); >- } >- >- } >- >- private void importWSDLImports(PortType pt, Definition importedWSDL) { >- List imports = importedWSDL.getEImports(); >- for (int i = 0; i < imports.size(); i++) { >- Import wsdlImport = (Import) imports.get(i); >- WsdlUtils.createWSDLImport(pt.getEnclosingDefinition(), wsdlImport >- .getNamespaceURI(), wsdlImport.getLocationURI()); >- } >- } >- >- private boolean importOperation(Operation newOperation, Operation importOp) { >- >- if(importOp.getName()==null || importOp.getName().equals("")) >- return false; >- >- String capNS = (String) _options.get(CapabilityWizardKeys.CAP_NS_KEY); >- if(!capNS.endsWith("/")) >- capNS = capNS+"/"; >- >- newOperation.setEnclosingDefinition(_wsdlCapDefinition); >- newOperation.setName(importOp.getName()); >- >- Input importInput = importOp.getEInput(); >- Output importOutput = importOp.getEOutput(); >- List importFaults = importOp.getEFaults(); >- >- if (importInput != null) { >- Input newInput = WSDLFactory.eINSTANCE.createInput(); >- newInput.setEnclosingDefinition(_wsdlCapDefinition); >- if(importInput.getName()!=null) >- newInput.setName(importInput.getName()); >- newInput.setEMessage(importInput.getEMessage()); >- newOperation.setEInput(newInput); >- WsdlUtils.createOrFindPrefix(_wsdlCapDefinition, WsdmConstants.WSA_URI, WsdmConstants.WSA_PREFIX); >- String opName = importOp.getName(); >- opName = opName.substring(0, 1).toUpperCase() + opName.substring(1); >- String action = capNS+opName+"Request"; >- newInput.getElement().setAttributeNS(WsdmConstants.WSA_URI, WsdmConstants.WSA_ACTION_NAME, action); >- } >- >- if (importOutput != null) { >- Output newOutput = WSDLFactory.eINSTANCE.createOutput(); >- newOutput.setEnclosingDefinition(_wsdlCapDefinition); >- if(importOutput.getName()!=null) >- newOutput.setName(importOutput.getName()); >- newOutput.setEMessage(importOutput.getEMessage()); >- newOperation.setEOutput(newOutput); >- WsdlUtils.createOrFindPrefix(_wsdlCapDefinition, WsdmConstants.WSA_URI, WsdmConstants.WSA_PREFIX); >- String opName = importOp.getName(); >- opName = opName.substring(0, 1).toUpperCase() + opName.substring(1); >- String action = capNS+opName+"Response"; >- newOutput.getElement().setAttributeNS(WsdmConstants.WSA_URI, WsdmConstants.WSA_ACTION_NAME, action); >- } >- >- for (int i = 0; i < importFaults.size(); i++) { >- Fault importFault = (Fault) importFaults.get(i); >- Fault newFault = WSDLFactory.eINSTANCE.createFault(); >- newFault.setName(importFault.getName()); >- newFault.setEMessage(importFault.getEMessage()); >- newOperation.addFault(newFault); >- } >- >- return true; >- } >- >- private String wsdlEdit(String wsdlString) { >- Document doc = parseToDOM(wsdlString); >- >- NodeList nlD = doc.getElementsByTagNameNS( >- WSDLConstants.WSDL_NAMESPACE_URI, "definitions"); >- Element defs = (Element) nlD.item(0); >- defs.setAttribute("xmlns:xsd", XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001); >- >- NodeList nlpt = doc.getElementsByTagNameNS( >- WSDLConstants.WSDL_NAMESPACE_URI, "portType"); >- Element pte = (Element) nlpt.item(0); >- String capName = (String) _options >- .get(CapabilityWizardKeys.CAP_NAME_KEY); >- String capPrefix = (String) _options >- .get(CapabilityWizardKeys.CAP_PREFIX_KEY); >- String rmdFileName = (String) _options >- .get(CapabilityWizardKeys.RMD_FILE_NAME_KEY); >- pte.setAttributeNS(WsdmConstants.WSRP_NS, "wsrp:" >- + WsdlUtils.RESOURCE_PROPERTIES_ELEMENT_KEY, capPrefix + ":" >- + capName + "Properties"); >- pte.setAttributeNS(WsdmConstants.WSRMD_NS, "wsrmd:" >- + WsdlUtils.METADATA_DESCRIPTOR_KEY, capName + "Descriptor"); >- pte.setAttributeNS(WsdmConstants.WSRMD_NS, "wsrmd:" >- + WsdlUtils.METADATA_DESCRIPTOR_LOCATION_KEY, rmdFileName); >- >- String serialized = prettySerializeDocument(doc); >- return serialized; >- } >- >- private Document parseToDOM(String xmlString) { >- Document doc = null; >- try { >- doc = XmlUtils.createDocument(xmlString); >- } catch (IOException ioe) { >- WsdmToolingLog.logError(Messages.CANT_PARSE_XML_ERROR_ + " ", ioe); >- return null; >- } catch (SAXException se) { >- WsdmToolingLog.logError(Messages.CANT_PARSE_XML_ERROR_ + " ", se); >- return null; >- } >- doc.normalize(); >- return doc; >- } >- >- private static String prettySerializeDocument(Document doc) { >- OutputFormat format = new OutputFormat(); >- format.setPreserveSpace(false); >- format.setIndenting(true); >- format.setIndent(2); >- format.setLineWidth(72); >- format.setLineSeparator(System.getProperty("line.separator")); >- StringWriter writer = new StringWriter(); >- XMLSerializer serializer = new XMLSerializer(writer, format); >- try { >- serializer.serialize(doc); >- } catch (IOException ioe) { >- WsdmToolingLog.logError(Messages.CANT_SERIALIZE_DOCUMENT_ERROR_ + " ", ioe); >- } >- return writer.getBuffer().toString(); >- } >- >- public void init(IWorkbench workbench, IStructuredSelection selection) { >- _selection = selection; >- setWindowTitle(Messages.NEW_CAPABILITY); >- } >- >- public NewCapabilityWizardPage getNewCapabilityWizardPage() { >- return _newCapPage; >- } >- >- /*protected CapabilityFileWizardPage getCapabilityFileWizardPage() { >- return _capFilesPage; >- }*/ >+ WsdmToolingLog.logError(Messages.FAILED_CREATE_CAP_ERROR_ + " ", e); >+ } >+ >+ String afterEdit = wsdlEdit(baos.toString()); >+ ByteArrayInputStream baInputStream = new ByteArrayInputStream(afterEdit >+ .getBytes()); >+ >+ try >+ { >+ if (capabilityFile.exists()) >+ { >+ capabilityFile.delete(true, null); >+ } >+ capabilityFile.create(baInputStream, true, null); >+ } catch (CoreException ce) >+ { >+ WsdmToolingLog >+ .logError(Messages.FAILED_CREATE_CAP_ERROR_ + " ", ce); >+ } >+ } >+ >+ private void createWSDLTypes() >+ { >+ Types types = WSDLFactory.eINSTANCE.createTypes(); >+ types.setEnclosingDefinition(_wsdlCapDefinition); >+ _wsdlCapDefinition.setETypes(types); >+ createResourcePropertiesSchema(); >+ } >+ >+ private void createResourcePropertiesSchema() >+ { >+ >+ String capNS = (String) _options.get(CapabilityWizardKeys.CAP_NS_KEY); >+ XSDSchema schema = WsdlUtils.createOrFindSchema(_wsdlCapDefinition, >+ capNS); >+ createAnnotation(schema); >+ if (isOverwriteXSD) >+ createPropXSDInclude(schema); >+ createResourceProperties(schema); >+ } >+ >+ private void createResourceProperties(XSDSchema schema) >+ { >+ String capName = (String) _options >+ .get(CapabilityWizardKeys.CAP_NAME_KEY); >+ XSDElementDeclaration resourcePropertyElement = XSDFactory.eINSTANCE >+ .createXSDElementDeclaration(); >+ resourcePropertyElement.setName(capName + "Properties"); >+ resourcePropertyElement.setTypeDefinition(null); >+ schema.getContents().add(resourcePropertyElement); >+ >+ XSDSchema[] importedXsd = (XSDSchema[]) _options >+ .get(CapabilityWizardKeys.IMPORT_XSD_KEY); >+ for (int i = 0; i < importedXsd.length; i++) >+ { >+ importXSD(resourcePropertyElement, importedXsd[i]); >+ } >+ } >+ >+ private void importXSD(XSDElementDeclaration resourcePropertyElement, >+ XSDSchema schema) >+ { >+ // Get the location for XSD Schema in drive fromat >+ String schemaLocation = XsdUtils.getLocalSystemSchemaLocation(schema); >+ >+ // Get the location for capability file >+ String capFileLocation = _capFile.getLocation().toString(); >+ >+ // Create xsd:import element >+ String importSchemaLocation = EclipseUtils.getRelativePath( >+ capFileLocation, schemaLocation, '/'); >+ XsdUtils.createImportStatement(resourcePropertyElement.getSchema(), >+ schema.getTargetNamespace(), importSchemaLocation); >+ >+ // Prepare resource property element >+ 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); >+ } >+ >+ List elements = schema.getElementDeclarations(); >+ for (int i = 0; i < elements.size(); i++) >+ { >+ // Add element to resource properties >+ XSDElementDeclaration element = (XSDElementDeclaration) elements >+ .get(i); >+ >+ XSDElementDeclaration propertyRef = XSDFactory.eINSTANCE >+ .createXSDElementDeclaration(); >+ propertyRef.setResolvedElementDeclaration(element); >+ XSDParticle simpleElementParticle = XSDFactory.eINSTANCE >+ .createXSDParticle(); >+ simpleElementParticle.setContent(propertyRef); >+ modelGroup.getContents().add(simpleElementParticle); >+ } >+ } >+ >+ private void createAnnotation(XSDSchema schema) >+ { >+ XSDAnnotation annotation = XSDFactory.eINSTANCE.createXSDAnnotation(); >+ schema.getContents().add(annotation); >+ Element documentation = annotation.createUserInformation(null); >+ annotation.getElement().appendChild(documentation); >+ documentation.appendChild(documentation.getOwnerDocument() >+ .createTextNode(DEFAULT_DESCRIPTION)); >+ } >+ >+ private void createPropXSDInclude(XSDSchema schema) >+ { >+ String xsdFileName = (String) _options >+ .get(CapabilityWizardKeys.XSD_FILE_NAME_KEY); >+ XSDInclude include = XSDFactory.eINSTANCE.createXSDInclude(); >+ include.setSchemaLocation(xsdFileName); >+ schema.getContents().add(include); >+ } >+ >+ private void createWSDLPortType() >+ { >+ PortType pt = WSDLFactory.eINSTANCE.createPortType(); >+ String capNS = (String) _options.get(CapabilityWizardKeys.CAP_NS_KEY); >+ String capName = (String) _options >+ .get(CapabilityWizardKeys.CAP_NAME_KEY); >+ pt.setQName(new QName(capNS, capName + "PortType")); >+ pt.setEnclosingDefinition(_wsdlCapDefinition); >+ _wsdlCapDefinition.addPortType(pt); >+ >+ Definition[] importedWSDL = (Definition[]) _options >+ .get(CapabilityWizardKeys.IMPORT_WSDL_KEY); >+ for (int i = 0; i < importedWSDL.length; i++) >+ { >+ importWSDL(pt, importedWSDL[i]); >+ } >+ } >+ >+ private void importWSDL(PortType pt, Definition importedWSDL) >+ { >+ importWSDLImports(pt, importedWSDL); >+ >+ // Get the location for imported WSDL >+ String importedWsdlLocation; >+ try >+ { >+ importedWsdlLocation = WsdlUtils >+ .getLocalSystemWSDLLocation(importedWSDL); >+ } catch (CoreException e) >+ { >+ return; >+ } >+ >+ // Get the location for capability file >+ String capFileLocation = _capFile.getLocation().toString(); >+ >+ // Create wsdl:import statement >+ String relativePath = EclipseUtils.getRelativePath(capFileLocation, >+ importedWsdlLocation, '/'); >+ WsdlUtils.createWSDLImport(pt.getEnclosingDefinition(), importedWSDL >+ .getTargetNamespace(), relativePath); >+ >+ PortType importPortType = WsdlUtils.getPortType(importedWSDL); >+ if (importPortType == null) >+ return; >+ List opList = importPortType.getEOperations(); >+ for (int i = 0; i < opList.size(); i++) >+ { >+ Operation importOp = (Operation) opList.get(i); >+ Operation newOperation = WSDLFactory.eINSTANCE.createOperation(); >+ pt.addOperation(newOperation); >+ if (!importOperation(newOperation, importOp)) >+ pt.getEOperations().remove(newOperation); >+ } >+ >+ } >+ >+ private void importWSDLImports(PortType pt, Definition importedWSDL) >+ { >+ List imports = importedWSDL.getEImports(); >+ for (int i = 0; i < imports.size(); i++) >+ { >+ Import wsdlImport = (Import) imports.get(i); >+ WsdlUtils.createWSDLImport(pt.getEnclosingDefinition(), wsdlImport >+ .getNamespaceURI(), wsdlImport.getLocationURI()); >+ } >+ } >+ >+ private boolean importOperation(Operation newOperation, Operation importOp) >+ { >+ >+ if (importOp.getName() == null || importOp.getName().equals("")) >+ return false; >+ >+ String capNS = (String) _options.get(CapabilityWizardKeys.CAP_NS_KEY); >+ if (!capNS.endsWith("/")) >+ capNS = capNS + "/"; >+ >+ newOperation.setEnclosingDefinition(_wsdlCapDefinition); >+ newOperation.setName(importOp.getName()); >+ >+ Input importInput = importOp.getEInput(); >+ Output importOutput = importOp.getEOutput(); >+ List importFaults = importOp.getEFaults(); >+ >+ if (importInput != null) >+ { >+ Input newInput = WSDLFactory.eINSTANCE.createInput(); >+ newInput.setEnclosingDefinition(_wsdlCapDefinition); >+ if (importInput.getName() != null) >+ newInput.setName(importInput.getName()); >+ newInput.setEMessage(importInput.getEMessage()); >+ newOperation.setEInput(newInput); >+ WsdlUtils.createOrFindPrefix(_wsdlCapDefinition, >+ WsdmConstants.WSA_URI, WsdmConstants.WSA_PREFIX); >+ String opName = importOp.getName(); >+ opName = opName.substring(0, 1).toUpperCase() + opName.substring(1); >+ String action = capNS + opName + "Request"; >+ newInput.getElement().setAttributeNS(WsdmConstants.WSA_URI, >+ WsdmConstants.WSA_ACTION_NAME, action); >+ } >+ >+ if (importOutput != null) >+ { >+ Output newOutput = WSDLFactory.eINSTANCE.createOutput(); >+ newOutput.setEnclosingDefinition(_wsdlCapDefinition); >+ if (importOutput.getName() != null) >+ newOutput.setName(importOutput.getName()); >+ newOutput.setEMessage(importOutput.getEMessage()); >+ newOperation.setEOutput(newOutput); >+ WsdlUtils.createOrFindPrefix(_wsdlCapDefinition, >+ WsdmConstants.WSA_URI, WsdmConstants.WSA_PREFIX); >+ String opName = importOp.getName(); >+ opName = opName.substring(0, 1).toUpperCase() + opName.substring(1); >+ String action = capNS + opName + "Response"; >+ newOutput.getElement().setAttributeNS(WsdmConstants.WSA_URI, >+ WsdmConstants.WSA_ACTION_NAME, action); >+ } >+ >+ for (int i = 0; i < importFaults.size(); i++) >+ { >+ Fault importFault = (Fault) importFaults.get(i); >+ Fault newFault = WSDLFactory.eINSTANCE.createFault(); >+ newFault.setName(importFault.getName()); >+ newFault.setEMessage(importFault.getEMessage()); >+ newOperation.addFault(newFault); >+ } >+ >+ return true; >+ } >+ >+ private String wsdlEdit(String wsdlString) >+ { >+ Document doc = null; >+ try >+ { >+ doc = CapUtils.createDocument(wsdlString); >+ } catch (Throwable e) >+ { >+ WsdmToolingLog.logError(e.getMessage(), e); >+ } >+ >+ NodeList nlD = doc.getElementsByTagNameNS( >+ WSDLConstants.WSDL_NAMESPACE_URI, "definitions"); >+ Element defs = (Element) nlD.item(0); >+ defs.setAttribute("xmlns:xsd", XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001); >+ >+ NodeList nlpt = doc.getElementsByTagNameNS( >+ WSDLConstants.WSDL_NAMESPACE_URI, "portType"); >+ Element pte = (Element) nlpt.item(0); >+ String capName = (String) _options >+ .get(CapabilityWizardKeys.CAP_NAME_KEY); >+ String capPrefix = (String) _options >+ .get(CapabilityWizardKeys.CAP_PREFIX_KEY); >+ String rmdFileName = (String) _options >+ .get(CapabilityWizardKeys.RMD_FILE_NAME_KEY); >+ pte.setAttributeNS(WsdmConstants.WSRP_NS, "wsrp:" >+ + WsdlUtils.RESOURCE_PROPERTIES_ELEMENT_KEY, capPrefix + ":" >+ + capName + "Properties"); >+ pte.setAttributeNS(WsdmConstants.WSRMD_NS, "wsrmd:" >+ + WsdlUtils.METADATA_DESCRIPTOR_KEY, capName + "Descriptor"); >+ pte.setAttributeNS(WsdmConstants.WSRMD_NS, "wsrmd:" >+ + WsdlUtils.METADATA_DESCRIPTOR_LOCATION_KEY, rmdFileName); >+ >+ String serialized = CapUtils.documentToString(doc); >+ return serialized; >+ } >+ >+ public void init(IWorkbench workbench, IStructuredSelection selection) >+ { >+ _selection = selection; >+ setWindowTitle(Messages.NEW_CAPABILITY); >+ } >+ >+ public NewCapabilityWizardPage getNewCapabilityWizardPage() >+ { >+ return _newCapPage; >+ } >+ >+ /* >+ * protected CapabilityFileWizardPage getCapabilityFileWizardPage() { return >+ * _capFilesPage; } >+ */ > } > >-class CapabilityWizardKeys { >+class CapabilityWizardKeys >+{ > >- static final String CONTAINER_NAME_KEY = "CONTAINER_NAME"; >+ static final String CONTAINER_NAME_KEY = "CONTAINER_NAME"; > >- static final String CAP_NS_KEY = "CAP_NS"; >+ static final String CAP_NS_KEY = "CAP_NS"; > >- static final String CAP_PREFIX_KEY = "CAP_PREFIX"; >+ static final String CAP_PREFIX_KEY = "CAP_PREFIX"; > >- static final String CAP_NAME_KEY = "CAP_NAME"; >+ static final String CAP_NAME_KEY = "CAP_NAME"; > >- static final String CAP_FILE_NAME_KEY = "CAP_FILE_NAME"; >+ static final String CAP_FILE_NAME_KEY = "CAP_FILE_NAME"; > >- static final String CAP_FILE_PATH_KEY = "CAP_FILE_PATH"; >+ static final String CAP_FILE_PATH_KEY = "CAP_FILE_PATH"; > >- static final String XSD_FILE_PATH_KEY = "XSD_FILE_PATH"; >+ static final String XSD_FILE_PATH_KEY = "XSD_FILE_PATH"; > >- static final String XSD_FILE_NAME_KEY = "XSD_FILE_NAME"; >+ static final String XSD_FILE_NAME_KEY = "XSD_FILE_NAME"; > >- static final String XSD_NS_KEY = "XSD_NS"; >+ static final String XSD_NS_KEY = "XSD_NS"; > >- static final String RMD_FILE_PATH_KEY = "RMD_FILE_PATH"; >+ static final String RMD_FILE_PATH_KEY = "RMD_FILE_PATH"; > >- static final String RMD_FILE_NAME_KEY = "RMD_FILE_NAME"; >+ static final String RMD_FILE_NAME_KEY = "RMD_FILE_NAME"; > >- static final String RMD_NS_KEY = "RMD_NS"; >+ static final String RMD_NS_KEY = "RMD_NS"; > >- static final String IMPORT_XSD_KEY = "IMPORT_XSD"; >+ static final String IMPORT_XSD_KEY = "IMPORT_XSD"; > >- static final String IMPORT_WSDL_KEY = "IMPORT_WSDL"; >+ static final String IMPORT_WSDL_KEY = "IMPORT_WSDL"; > } >#P org.eclipse.tptp.wsdm.tooling.model >Index: src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/MetadataDescriptorType.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.model/src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/MetadataDescriptorType.java,v >retrieving revision 1.2 >diff -u -r1.2 MetadataDescriptorType.java >--- src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/MetadataDescriptorType.java 13 Sep 2006 12:05:49 -0000 1.2 >+++ src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/MetadataDescriptorType.java 20 Jan 2007 13:34:15 -0000 >@@ -11,8 +11,6 @@ > *******************************************************************************/ > package org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor; > >-import java.util.List; >- > import org.eclipse.emf.common.util.EList; > > import org.eclipse.emf.ecore.util.FeatureMap; >@@ -82,13 +80,13 @@ > * </p> > * <!-- end-user-doc --> > * @return the value of the '<em>Interface</em>' attribute. >- * @see #setInterface(Object) >+ * @see #setInterface(String) > * @see org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.MetadataDescriptorPackage#getMetadataDescriptorType_Interface() >- * @model unique="false" dataType="org.eclipse.emf.ecore.xml.type.QName" required="true" >+ * @model unique="false" dataType="org.eclipse.emf.ecore.xml.type.NCName" required="true" > * extendedMetaData="kind='attribute' name='interface'" > * @generated > */ >- Object getInterface(); >+ String getInterface(); > > /** > * Sets the value of the '{@link org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.MetadataDescriptorType#getInterface <em>Interface</em>}' attribute. >@@ -98,7 +96,7 @@ > * @see #getInterface() > * @generated > */ >- void setInterface(Object value); >+ void setInterface(String value); > > /** > * Returns the value of the '<em><b>Name</b></em>' attribute. >@@ -136,13 +134,13 @@ > * </p> > * <!-- end-user-doc --> > * @return the value of the '<em>Wsdl Location</em>' attribute. >- * @see #setWsdlLocation(List) >+ * @see #setWsdlLocation(String) > * @see org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.MetadataDescriptorPackage#getMetadataDescriptorType_WsdlLocation() >- * @model unique="false" dataType="org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.PairsOfURIType" many="false" >+ * @model unique="false" dataType="org.eclipse.emf.ecore.xml.type.String" > * extendedMetaData="kind='attribute' name='wsdlLocation'" > * @generated > */ >- List getWsdlLocation(); >+ String getWsdlLocation(); > > /** > * Sets the value of the '{@link org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.MetadataDescriptorType#getWsdlLocation <em>Wsdl Location</em>}' attribute. >@@ -152,7 +150,7 @@ > * @see #getWsdlLocation() > * @generated > */ >- void setWsdlLocation(List value); >+ void setWsdlLocation(String value); > > /** > * Returns the value of the '<em><b>Any Attribute</b></em>' attribute list. >@@ -171,4 +169,4 @@ > */ > FeatureMap getAnyAttribute(); > >-} // MetadataDescriptorType >+} // MetadataDescriptorType >\ No newline at end of file >Index: src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/DefinitionsType.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.model/src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/DefinitionsType.java,v >retrieving revision 1.2 >diff -u -r1.2 DefinitionsType.java >--- src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/DefinitionsType.java 13 Sep 2006 12:05:49 -0000 1.2 >+++ src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/DefinitionsType.java 20 Jan 2007 13:34:08 -0000 >@@ -113,4 +113,4 @@ > */ > FeatureMap getAnyAttribute(); > >-} // DefinitionsType >+} // DefinitionsType >\ No newline at end of file >Index: src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/DocumentRoot.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.model/src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/DocumentRoot.java,v >retrieving revision 1.2 >diff -u -r1.2 DocumentRoot.java >--- src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/DocumentRoot.java 13 Sep 2006 12:05:49 -0000 1.2 >+++ src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/DocumentRoot.java 20 Jan 2007 13:34:09 -0000 >@@ -397,4 +397,4 @@ > */ > void setDescriptorLocation(String value); > >-} // DocumentRoot >+} // DocumentRoot >\ No newline at end of file >Index: src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/DocumentedType.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.model/src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/DocumentedType.java,v >retrieving revision 1.2 >diff -u -r1.2 DocumentedType.java >--- src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/DocumentedType.java 13 Sep 2006 12:05:49 -0000 1.2 >+++ src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/DocumentedType.java 20 Jan 2007 13:34:10 -0000 >@@ -57,4 +57,4 @@ > */ > void setDocumentation(DocumentationType value); > >-} // DocumentedType >+} // DocumentedType >\ No newline at end of file >Index: src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/DocumentationType.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.model/src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/DocumentationType.java,v >retrieving revision 1.2 >diff -u -r1.2 DocumentationType.java >--- src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/DocumentationType.java 13 Sep 2006 12:05:49 -0000 1.2 >+++ src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/DocumentationType.java 20 Jan 2007 13:34:10 -0000 >@@ -85,4 +85,4 @@ > */ > FeatureMap getAnyAttribute(); > >-} // DocumentationType >+} // DocumentationType >\ No newline at end of file >Index: src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/StaticValuesType.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.model/src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/StaticValuesType.java,v >retrieving revision 1.2 >diff -u -r1.2 StaticValuesType.java >--- src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/StaticValuesType.java 13 Sep 2006 12:05:49 -0000 1.2 >+++ src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/StaticValuesType.java 20 Jan 2007 13:34:16 -0000 >@@ -113,4 +113,4 @@ > */ > FeatureMap getAnyAttribute(); > >-} // StaticValuesType >+} // StaticValuesType >\ No newline at end of file >Index: src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/MetadataDescriptorReferenceType.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.model/src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/MetadataDescriptorReferenceType.java,v >retrieving revision 1.2 >diff -u -r1.2 MetadataDescriptorReferenceType.java >--- src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/MetadataDescriptorReferenceType.java 13 Sep 2006 12:05:49 -0000 1.2 >+++ src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/MetadataDescriptorReferenceType.java 20 Jan 2007 13:34:14 -0000 >@@ -24,4 +24,4 @@ > * @generated > */ > public interface MetadataDescriptorReferenceType extends EndpointReferenceType { >-} // MetadataDescriptorReferenceType >+} // MetadataDescriptorReferenceType >\ No newline at end of file >Index: src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/InitialValuesType.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.model/src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/InitialValuesType.java,v >retrieving revision 1.2 >diff -u -r1.2 InitialValuesType.java >--- src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/InitialValuesType.java 13 Sep 2006 12:05:49 -0000 1.2 >+++ src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/InitialValuesType.java 20 Jan 2007 13:34:10 -0000 >@@ -113,4 +113,4 @@ > */ > FeatureMap getAnyAttribute(); > >-} // InitialValuesType >+} // InitialValuesType >\ No newline at end of file >Index: src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/PropertyType.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.model/src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/PropertyType.java,v >retrieving revision 1.2 >diff -u -r1.2 PropertyType.java >--- src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/PropertyType.java 13 Sep 2006 12:05:49 -0000 1.2 >+++ src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/PropertyType.java 20 Jan 2007 13:34:16 -0000 >@@ -289,13 +289,13 @@ > * </p> > * <!-- end-user-doc --> > * @return the value of the '<em>Name</em>' attribute. >- * @see #setName(Object) >+ * @see #setName(String) > * @see org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.MetadataDescriptorPackage#getPropertyType_Name() >- * @model unique="false" dataType="org.eclipse.emf.ecore.xml.type.QName" required="true" >+ * @model unique="false" dataType="org.eclipse.emf.ecore.xml.type.NCName" required="true" > * extendedMetaData="kind='attribute' name='name'" > * @generated > */ >- Object getName(); >+ String getName(); > > /** > * Sets the value of the '{@link org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.PropertyType#getName <em>Name</em>}' attribute. >@@ -305,7 +305,7 @@ > * @see #getName() > * @generated > */ >- void setName(Object value); >+ void setName(String value); > > /** > * Returns the value of the '<em><b>Subscribability</b></em>' attribute. >@@ -379,4 +379,4 @@ > */ > FeatureMap getAnyAttribute(); > >-} // PropertyType >+} // PropertyType >\ No newline at end of file >Index: src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/ValidValueRangeType.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.model/src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/ValidValueRangeType.java,v >retrieving revision 1.2 >diff -u -r1.2 ValidValueRangeType.java >--- src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/ValidValueRangeType.java 13 Sep 2006 12:05:49 -0000 1.2 >+++ src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/ValidValueRangeType.java 20 Jan 2007 13:34:17 -0000 >@@ -169,4 +169,4 @@ > */ > FeatureMap getAnyAttribute(); > >-} // ValidValueRangeType >+} // ValidValueRangeType >\ No newline at end of file >Index: src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/ValidValuesType.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.model/src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/ValidValuesType.java,v >retrieving revision 1.2 >diff -u -r1.2 ValidValuesType.java >--- src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/ValidValuesType.java 13 Sep 2006 12:05:49 -0000 1.2 >+++ src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/ValidValuesType.java 20 Jan 2007 13:34:17 -0000 >@@ -113,4 +113,4 @@ > */ > FeatureMap getAnyAttribute(); > >-} // ValidValuesType >+} // ValidValuesType >\ No newline at end of file >Index: src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/impl/StaticValuesTypeImpl.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.model/src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/impl/StaticValuesTypeImpl.java,v >retrieving revision 1.2 >diff -u -r1.2 StaticValuesTypeImpl.java >--- src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/impl/StaticValuesTypeImpl.java 13 Sep 2006 12:05:55 -0000 1.2 >+++ src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/impl/StaticValuesTypeImpl.java 20 Jan 2007 13:34:26 -0000 >@@ -264,4 +264,4 @@ > return result.toString(); > } > >-} //StaticValuesTypeImpl >+} //StaticValuesTypeImpl >\ No newline at end of file >Index: src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/impl/ValidValuesTypeImpl.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.model/src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/impl/ValidValuesTypeImpl.java,v >retrieving revision 1.2 >diff -u -r1.2 ValidValuesTypeImpl.java >--- src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/impl/ValidValuesTypeImpl.java 13 Sep 2006 12:05:55 -0000 1.2 >+++ src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/impl/ValidValuesTypeImpl.java 20 Jan 2007 13:34:27 -0000 >@@ -264,4 +264,4 @@ > return result.toString(); > } > >-} //ValidValuesTypeImpl >+} //ValidValuesTypeImpl >\ No newline at end of file >Index: src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/impl/DocumentedTypeImpl.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.model/src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/impl/DocumentedTypeImpl.java,v >retrieving revision 1.2 >diff -u -r1.2 DocumentedTypeImpl.java >--- src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/impl/DocumentedTypeImpl.java 13 Sep 2006 12:05:55 -0000 1.2 >+++ src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/impl/DocumentedTypeImpl.java 20 Jan 2007 13:34:20 -0000 >@@ -176,4 +176,4 @@ > return super.eIsSet(featureID); > } > >-} //DocumentedTypeImpl >+} //DocumentedTypeImpl >\ No newline at end of file >Index: src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/impl/DocumentationTypeImpl.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.model/src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/impl/DocumentationTypeImpl.java,v >retrieving revision 1.2 >diff -u -r1.2 DocumentationTypeImpl.java >--- src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/impl/DocumentationTypeImpl.java 13 Sep 2006 12:05:55 -0000 1.2 >+++ src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/impl/DocumentationTypeImpl.java 20 Jan 2007 13:34:19 -0000 >@@ -223,4 +223,4 @@ > return result.toString(); > } > >-} //DocumentationTypeImpl >+} //DocumentationTypeImpl >\ No newline at end of file >Index: src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/impl/MetadataDescriptorPackageImpl.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.model/src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/impl/MetadataDescriptorPackageImpl.java,v >retrieving revision 1.2 >diff -u -r1.2 MetadataDescriptorPackageImpl.java >--- src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/impl/MetadataDescriptorPackageImpl.java 13 Sep 2006 12:05:55 -0000 1.2 >+++ src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/impl/MetadataDescriptorPackageImpl.java 20 Jan 2007 13:34:24 -0000 >@@ -1133,9 +1133,9 @@ > initEClass(metadataDescriptorTypeEClass, MetadataDescriptorType.class, "MetadataDescriptorType", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); > initEReference(getMetadataDescriptorType_Property(), this.getPropertyType(), null, "property", null, 0, -1, MetadataDescriptorType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); > initEAttribute(getMetadataDescriptorType_Any(), ecorePackage.getEFeatureMapEntry(), "any", null, 0, -1, MetadataDescriptorType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); >- initEAttribute(getMetadataDescriptorType_Interface(), theXMLTypePackage.getQName(), "interface", null, 1, 1, MetadataDescriptorType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); >+ initEAttribute(getMetadataDescriptorType_Interface(), theXMLTypePackage.getNCName(), "interface", null, 1, 1, MetadataDescriptorType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); > initEAttribute(getMetadataDescriptorType_Name(), theXMLTypePackage.getNCName(), "name", null, 1, 1, MetadataDescriptorType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); >- initEAttribute(getMetadataDescriptorType_WsdlLocation(), this.getPairsOfURIType(), "wsdlLocation", null, 0, 1, MetadataDescriptorType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); >+ initEAttribute(getMetadataDescriptorType_WsdlLocation(), theXMLTypePackage.getString(), "wsdlLocation", null, 0, 1, MetadataDescriptorType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); > initEAttribute(getMetadataDescriptorType_AnyAttribute(), ecorePackage.getEFeatureMapEntry(), "anyAttribute", null, 0, -1, MetadataDescriptorType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); > > initEClass(propertyTypeEClass, PropertyType.class, "PropertyType", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); >@@ -1146,7 +1146,7 @@ > initEAttribute(getPropertyType_Any(), ecorePackage.getEFeatureMapEntry(), "any", null, 0, -1, PropertyType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); > initEAttribute(getPropertyType_Modifiability(), this.getModifiabilityType(), "modifiability", "read-only", 0, 1, PropertyType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); > initEAttribute(getPropertyType_Mutability(), this.getMutabilityType(), "mutability", "constant", 0, 1, PropertyType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); >- initEAttribute(getPropertyType_Name(), theXMLTypePackage.getQName(), "name", null, 1, 1, PropertyType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); >+ initEAttribute(getPropertyType_Name(), theXMLTypePackage.getNCName(), "name", null, 1, 1, PropertyType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); > initEAttribute(getPropertyType_Subscribability(), theXMLTypePackage.getBoolean(), "subscribability", "false", 0, 1, PropertyType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); > initEAttribute(getPropertyType_AnyAttribute(), ecorePackage.getEFeatureMapEntry(), "anyAttribute", null, 0, -1, PropertyType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); > >Index: src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/impl/MetadataDescriptorTypeImpl.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.model/src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/impl/MetadataDescriptorTypeImpl.java,v >retrieving revision 1.2 >diff -u -r1.2 MetadataDescriptorTypeImpl.java >--- src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/impl/MetadataDescriptorTypeImpl.java 13 Sep 2006 12:05:55 -0000 1.2 >+++ src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/impl/MetadataDescriptorTypeImpl.java 20 Jan 2007 13:34:24 -0000 >@@ -12,7 +12,6 @@ > package org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.impl; > > import java.util.Collection; >-import java.util.List; > > import org.eclipse.emf.common.notify.Notification; > import org.eclipse.emf.common.notify.NotificationChain; >@@ -80,7 +79,7 @@ > * @generated > * @ordered > */ >- protected static final Object INTERFACE_EDEFAULT = null; >+ protected static final String INTERFACE_EDEFAULT = null; > > /** > * The cached value of the '{@link #getInterface() <em>Interface</em>}' attribute. >@@ -90,7 +89,7 @@ > * @generated > * @ordered > */ >- protected Object interface_ = INTERFACE_EDEFAULT; >+ protected String interface_ = INTERFACE_EDEFAULT; > > /** > * The default value of the '{@link #getName() <em>Name</em>}' attribute. >@@ -120,7 +119,7 @@ > * @generated > * @ordered > */ >- protected static final List WSDL_LOCATION_EDEFAULT = null; >+ protected static final String WSDL_LOCATION_EDEFAULT = null; > > /** > * The cached value of the '{@link #getWsdlLocation() <em>Wsdl Location</em>}' attribute. >@@ -130,7 +129,7 @@ > * @generated > * @ordered > */ >- protected List wsdlLocation = WSDL_LOCATION_EDEFAULT; >+ protected String wsdlLocation = WSDL_LOCATION_EDEFAULT; > > /** > * The cached value of the '{@link #getAnyAttribute() <em>Any Attribute</em>}' attribute list. >@@ -189,7 +188,7 @@ > * <!-- end-user-doc --> > * @generated > */ >- public Object getInterface() { >+ public String getInterface() { > return interface_; > } > >@@ -198,8 +197,8 @@ > * <!-- end-user-doc --> > * @generated > */ >- public void setInterface(Object newInterface) { >- Object oldInterface = interface_; >+ public void setInterface(String newInterface) { >+ String oldInterface = interface_; > interface_ = newInterface; > if (eNotificationRequired()) > eNotify(new ENotificationImpl(this, Notification.SET, MetadataDescriptorPackage.METADATA_DESCRIPTOR_TYPE__INTERFACE, oldInterface, interface_)); >@@ -231,7 +230,7 @@ > * <!-- end-user-doc --> > * @generated > */ >- public List getWsdlLocation() { >+ public String getWsdlLocation() { > return wsdlLocation; > } > >@@ -240,8 +239,8 @@ > * <!-- end-user-doc --> > * @generated > */ >- public void setWsdlLocation(List newWsdlLocation) { >- List oldWsdlLocation = wsdlLocation; >+ public void setWsdlLocation(String newWsdlLocation) { >+ String oldWsdlLocation = wsdlLocation; > wsdlLocation = newWsdlLocation; > if (eNotificationRequired()) > eNotify(new ENotificationImpl(this, Notification.SET, MetadataDescriptorPackage.METADATA_DESCRIPTOR_TYPE__WSDL_LOCATION, oldWsdlLocation, wsdlLocation)); >@@ -316,13 +315,13 @@ > ((FeatureMap.Internal)getAny()).set(newValue); > return; > case MetadataDescriptorPackage.METADATA_DESCRIPTOR_TYPE__INTERFACE: >- setInterface((Object)newValue); >+ setInterface((String)newValue); > return; > case MetadataDescriptorPackage.METADATA_DESCRIPTOR_TYPE__NAME: > setName((String)newValue); > return; > case MetadataDescriptorPackage.METADATA_DESCRIPTOR_TYPE__WSDL_LOCATION: >- setWsdlLocation((List)newValue); >+ setWsdlLocation((String)newValue); > return; > case MetadataDescriptorPackage.METADATA_DESCRIPTOR_TYPE__ANY_ATTRIBUTE: > ((FeatureMap.Internal)getAnyAttribute()).set(newValue); >@@ -406,4 +405,4 @@ > return result.toString(); > } > >-} //MetadataDescriptorTypeImpl >+} //MetadataDescriptorTypeImpl >\ No newline at end of file >Index: src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/impl/DocumentRootImpl.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.model/src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/impl/DocumentRootImpl.java,v >retrieving revision 1.2 >diff -u -r1.2 DocumentRootImpl.java >--- src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/impl/DocumentRootImpl.java 13 Sep 2006 12:05:55 -0000 1.2 >+++ src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/impl/DocumentRootImpl.java 20 Jan 2007 13:34:19 -0000 >@@ -718,4 +718,4 @@ > return result.toString(); > } > >-} //DocumentRootImpl >+} //DocumentRootImpl >\ No newline at end of file >Index: src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/impl/ValidValueRangeTypeImpl.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.model/src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/impl/ValidValueRangeTypeImpl.java,v >retrieving revision 1.2 >diff -u -r1.2 ValidValueRangeTypeImpl.java >--- src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/impl/ValidValueRangeTypeImpl.java 13 Sep 2006 12:05:55 -0000 1.2 >+++ src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/impl/ValidValueRangeTypeImpl.java 20 Jan 2007 13:34:26 -0000 >@@ -374,4 +374,4 @@ > return result.toString(); > } > >-} //ValidValueRangeTypeImpl >+} //ValidValueRangeTypeImpl >\ No newline at end of file >Index: src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/impl/InitialValuesTypeImpl.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.model/src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/impl/InitialValuesTypeImpl.java,v >retrieving revision 1.2 >diff -u -r1.2 InitialValuesTypeImpl.java >--- src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/impl/InitialValuesTypeImpl.java 13 Sep 2006 12:05:55 -0000 1.2 >+++ src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/impl/InitialValuesTypeImpl.java 20 Jan 2007 13:34:20 -0000 >@@ -264,4 +264,4 @@ > return result.toString(); > } > >-} //InitialValuesTypeImpl >+} //InitialValuesTypeImpl >\ No newline at end of file >Index: src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/impl/MetadataDescriptorReferenceTypeImpl.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.model/src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/impl/MetadataDescriptorReferenceTypeImpl.java,v >retrieving revision 1.2 >diff -u -r1.2 MetadataDescriptorReferenceTypeImpl.java >--- src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/impl/MetadataDescriptorReferenceTypeImpl.java 13 Sep 2006 12:05:55 -0000 1.2 >+++ src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/impl/MetadataDescriptorReferenceTypeImpl.java 20 Jan 2007 13:34:24 -0000 >@@ -46,4 +46,4 @@ > return MetadataDescriptorPackage.Literals.METADATA_DESCRIPTOR_REFERENCE_TYPE; > } > >-} //MetadataDescriptorReferenceTypeImpl >+} //MetadataDescriptorReferenceTypeImpl >\ No newline at end of file >Index: src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/impl/PropertyTypeImpl.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.model/src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/impl/PropertyTypeImpl.java,v >retrieving revision 1.2 >diff -u -r1.2 PropertyTypeImpl.java >--- src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/impl/PropertyTypeImpl.java 13 Sep 2006 12:05:55 -0000 1.2 >+++ src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/impl/PropertyTypeImpl.java 20 Jan 2007 13:34:25 -0000 >@@ -171,7 +171,7 @@ > * @generated > * @ordered > */ >- protected static final Object NAME_EDEFAULT = null; >+ protected static final String NAME_EDEFAULT = null; > > /** > * The cached value of the '{@link #getName() <em>Name</em>}' attribute. >@@ -181,7 +181,7 @@ > * @generated > * @ordered > */ >- protected Object name = NAME_EDEFAULT; >+ protected String name = NAME_EDEFAULT; > > /** > * The default value of the '{@link #isSubscribability() <em>Subscribability</em>}' attribute. >@@ -521,7 +521,7 @@ > * <!-- end-user-doc --> > * @generated > */ >- public Object getName() { >+ public String getName() { > return name; > } > >@@ -530,8 +530,8 @@ > * <!-- end-user-doc --> > * @generated > */ >- public void setName(Object newName) { >- Object oldName = name; >+ public void setName(String newName) { >+ String oldName = name; > name = newName; > if (eNotificationRequired()) > eNotify(new ENotificationImpl(this, Notification.SET, MetadataDescriptorPackage.PROPERTY_TYPE__NAME, oldName, name)); >@@ -680,7 +680,7 @@ > setMutability((MutabilityType)newValue); > return; > case MetadataDescriptorPackage.PROPERTY_TYPE__NAME: >- setName((Object)newValue); >+ setName((String)newValue); > return; > case MetadataDescriptorPackage.PROPERTY_TYPE__SUBSCRIBABILITY: > setSubscribability(((Boolean)newValue).booleanValue()); >@@ -789,4 +789,4 @@ > return result.toString(); > } > >-} //PropertyTypeImpl >+} //PropertyTypeImpl >\ No newline at end of file >Index: src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/impl/DefinitionsTypeImpl.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.model/src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/impl/DefinitionsTypeImpl.java,v >retrieving revision 1.2 >diff -u -r1.2 DefinitionsTypeImpl.java >--- src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/impl/DefinitionsTypeImpl.java 13 Sep 2006 12:05:55 -0000 1.2 >+++ src/org/eclipse/tptp/wsdm/tooling/model/metadataDescriptor/impl/DefinitionsTypeImpl.java 20 Jan 2007 13:34:17 -0000 >@@ -297,4 +297,4 @@ > return result.toString(); > } > >-} //DefinitionsTypeImpl >+} //DefinitionsTypeImpl >\ No newline at end of file >Index: src/org/eclipse/tptp/wsdm/tooling/model/capabilities/util/CapabilitiesAdapterFactory.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.model/src/org/eclipse/tptp/wsdm/tooling/model/capabilities/util/CapabilitiesAdapterFactory.java,v >retrieving revision 1.7 >diff -u -r1.7 CapabilitiesAdapterFactory.java >--- src/org/eclipse/tptp/wsdm/tooling/model/capabilities/util/CapabilitiesAdapterFactory.java 13 Sep 2006 12:05:52 -0000 1.7 >+++ src/org/eclipse/tptp/wsdm/tooling/model/capabilities/util/CapabilitiesAdapterFactory.java 20 Jan 2007 13:34:08 -0000 >@@ -20,6 +20,8 @@ > > import org.eclipse.tptp.wsdm.tooling.model.capabilities.*; > >+import org.eclipse.tptp.wsdm.tooling.model.capabilities.impl.MetadataDescriptor; >+ > /** > * <!-- begin-user-doc --> > * The <b>Adapter Factory</b> for the model. >@@ -87,6 +89,12 @@ > public Object caseProperty(Property object) { > return createPropertyAdapter(); > } >+ public Object caseMetadata(MetadataDescriptor object) { >+ return createMetadataAdapter(); >+ } >+ public Object caseMetrics(Metrics object) { >+ return createMetricsAdapter(); >+ } > public Object defaultCase(EObject object) { > return createEObjectAdapter(); > } >@@ -162,6 +170,34 @@ > } > > /** >+ * Creates a new adapter for an object of class '{@link org.eclipse.tptp.wsdm.tooling.model.capabilities.impl.MetadataDescriptor <em>Metadata</em>}'. >+ * <!-- begin-user-doc --> >+ * This default implementation returns null so that we can easily ignore cases; >+ * it's useful to ignore a case when inheritance will catch all the cases anyway. >+ * <!-- end-user-doc --> >+ * @return the new adapter. >+ * @see org.eclipse.tptp.wsdm.tooling.model.capabilities.impl.MetadataDescriptor >+ * @generated >+ */ >+ public Adapter createMetadataAdapter() { >+ return null; >+ } >+ >+ /** >+ * Creates a new adapter for an object of class '{@link org.eclipse.tptp.wsdm.tooling.model.capabilities.Metrics <em>Metrics</em>}'. >+ * <!-- begin-user-doc --> >+ * This default implementation returns null so that we can easily ignore cases; >+ * it's useful to ignore a case when inheritance will catch all the cases anyway. >+ * <!-- end-user-doc --> >+ * @return the new adapter. >+ * @see org.eclipse.tptp.wsdm.tooling.model.capabilities.Metrics >+ * @generated >+ */ >+ public Adapter createMetricsAdapter() { >+ return null; >+ } >+ >+ /** > * Creates a new adapter for the default case. > * <!-- begin-user-doc --> > * This default implementation returns null. >Index: src/org/eclipse/tptp/wsdm/tooling/model/capabilities/util/CapabilitiesSwitch.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.model/src/org/eclipse/tptp/wsdm/tooling/model/capabilities/util/CapabilitiesSwitch.java,v >retrieving revision 1.7 >diff -u -r1.7 CapabilitiesSwitch.java >--- src/org/eclipse/tptp/wsdm/tooling/model/capabilities/util/CapabilitiesSwitch.java 13 Sep 2006 12:05:52 -0000 1.7 >+++ src/org/eclipse/tptp/wsdm/tooling/model/capabilities/util/CapabilitiesSwitch.java 20 Jan 2007 13:34:08 -0000 >@@ -18,6 +18,8 @@ > > import org.eclipse.tptp.wsdm.tooling.model.capabilities.*; > >+import org.eclipse.tptp.wsdm.tooling.model.capabilities.impl.MetadataDescriptor; >+ > /** > * <!-- begin-user-doc --> > * The <b>Switch</b> for the model's inheritance hierarchy. >@@ -116,6 +118,12 @@ > if (result == null) result = defaultCase(theEObject); > return result; > } >+ case CapabilitiesPackage.METRICS: { >+ Metrics metrics = (Metrics)theEObject; >+ Object result = caseMetrics(metrics); >+ if (result == null) result = defaultCase(theEObject); >+ return result; >+ } > default: return defaultCase(theEObject); > } > } >@@ -181,6 +189,36 @@ > } > > /** >+ * Returns the result of interpretting the object as an instance of '<em>Metadata</em>'. >+ * <!-- begin-user-doc --> >+ * This implementation returns null; >+ * returning a non-null result will terminate the switch. >+ * <!-- end-user-doc --> >+ * @param object the target of the switch. >+ * @return the result of interpretting the object as an instance of '<em>Metadata</em>'. >+ * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) >+ * @generated >+ */ >+ public Object caseMetadata(MetadataDescriptor object) { >+ return null; >+ } >+ >+ /** >+ * Returns the result of interpretting the object as an instance of '<em>Metrics</em>'. >+ * <!-- begin-user-doc --> >+ * This implementation returns null; >+ * returning a non-null result will terminate the switch. >+ * <!-- end-user-doc --> >+ * @param object the target of the switch. >+ * @return the result of interpretting the object as an instance of '<em>Metrics</em>'. >+ * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) >+ * @generated >+ */ >+ public Object caseMetrics(Metrics object) { >+ return null; >+ } >+ >+ /** > * Returns the result of interpretting the object as an instance of '<em>EObject</em>'. > * <!-- begin-user-doc --> > * This implementation returns null; >Index: src/org/eclipse/tptp/wsdm/tooling/model/capabilities/CapabilitiesPackage.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.model/src/org/eclipse/tptp/wsdm/tooling/model/capabilities/CapabilitiesPackage.java,v >retrieving revision 1.7 >diff -u -r1.7 CapabilitiesPackage.java >--- src/org/eclipse/tptp/wsdm/tooling/model/capabilities/CapabilitiesPackage.java 13 Sep 2006 12:05:49 -0000 1.7 >+++ src/org/eclipse/tptp/wsdm/tooling/model/capabilities/CapabilitiesPackage.java 20 Jan 2007 13:34:04 -0000 >@@ -138,13 +138,31 @@ > int CAPABILITY__TOPIC_SPACES = 6; > > /** >+ * The feature id for the '<em><b>Definition</b></em>' reference. >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated >+ * @ordered >+ */ >+ int CAPABILITY__DEFINITION = 7; >+ >+ /** >+ * The feature id for the '<em><b>Metadata</b></em>' reference. >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated >+ * @ordered >+ */ >+ int CAPABILITY__METADATA = 8; >+ >+ /** > * The number of structural features of the '<em>Capability</em>' class. > * <!-- begin-user-doc --> > * <!-- end-user-doc --> > * @generated > * @ordered > */ >- int CAPABILITY_FEATURE_COUNT = 7; >+ int CAPABILITY_FEATURE_COUNT = 9; > > /** > * The meta object id for the '{@link org.eclipse.tptp.wsdm.tooling.model.capabilities.impl.TopicSpaceImpl <em>Topic Space</em>}' class. >@@ -303,13 +321,98 @@ > int PROPERTY__META_DATA = 1; > > /** >+ * The feature id for the '<em><b>Metrics</b></em>' reference. >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated >+ * @ordered >+ */ >+ int PROPERTY__METRICS = 2; >+ >+ /** > * The number of structural features of the '<em>Property</em>' class. > * <!-- begin-user-doc --> > * <!-- end-user-doc --> > * @generated > * @ordered > */ >- int PROPERTY_FEATURE_COUNT = 2; >+ int PROPERTY_FEATURE_COUNT = 3; >+ >+ >+ /** >+ * The meta object id for the '{@link org.eclipse.tptp.wsdm.tooling.model.capabilities.impl.MetadataDescriptor <em>Metadata</em>}' class. >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @see org.eclipse.tptp.wsdm.tooling.model.capabilities.impl.MetadataDescriptor >+ * @see org.eclipse.tptp.wsdm.tooling.model.capabilities.impl.CapabilitiesPackageImpl#getMetadata() >+ * @generated >+ */ >+ int METADATA = 4; >+ >+ /** >+ * The number of structural features of the '<em>Metadata</em>' class. >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated >+ * @ordered >+ */ >+ int METADATA_FEATURE_COUNT = 0; >+ >+ >+ /** >+ * The meta object id for the '{@link org.eclipse.tptp.wsdm.tooling.model.capabilities.impl.MetricsImpl <em>Metrics</em>}' class. >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @see org.eclipse.tptp.wsdm.tooling.model.capabilities.impl.MetricsImpl >+ * @see org.eclipse.tptp.wsdm.tooling.model.capabilities.impl.CapabilitiesPackageImpl#getMetrics() >+ * @generated >+ */ >+ int METRICS = 5; >+ >+ /** >+ * The feature id for the '<em><b>Change Type</b></em>' attribute. >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated >+ * @ordered >+ */ >+ int METRICS__CHANGE_TYPE = 0; >+ >+ /** >+ * The feature id for the '<em><b>Time Scope</b></em>' attribute. >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated >+ * @ordered >+ */ >+ int METRICS__TIME_SCOPE = 1; >+ >+ /** >+ * The feature id for the '<em><b>Gathering Time</b></em>' attribute. >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated >+ * @ordered >+ */ >+ int METRICS__GATHERING_TIME = 2; >+ >+ /** >+ * The feature id for the '<em><b>Calculation Interval</b></em>' attribute. >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated >+ * @ordered >+ */ >+ int METRICS__CALCULATION_INTERVAL = 3; >+ >+ /** >+ * The number of structural features of the '<em>Metrics</em>' class. >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated >+ * @ordered >+ */ >+ int METRICS_FEATURE_COUNT = 4; > > > /** >@@ -400,6 +503,28 @@ > EReference getCapability_TopicSpaces(); > > /** >+ * Returns the meta object for the reference '{@link org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability#getDefinition <em>Definition</em>}'. >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @return the meta object for the reference '<em>Definition</em>'. >+ * @see org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability#getDefinition() >+ * @see #getCapability() >+ * @generated >+ */ >+ EReference getCapability_Definition(); >+ >+ /** >+ * Returns the meta object for the reference '{@link org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability#getMetadata <em>Metadata</em>}'. >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @return the meta object for the reference '<em>Metadata</em>'. >+ * @see org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability#getMetadata() >+ * @see #getCapability() >+ * @generated >+ */ >+ EReference getCapability_Metadata(); >+ >+ /** > * Returns the meta object for class '{@link org.eclipse.tptp.wsdm.tooling.model.capabilities.TopicSpace <em>Topic Space</em>}'. > * <!-- begin-user-doc --> > * <!-- end-user-doc --> >@@ -562,6 +687,82 @@ > EReference getProperty_MetaData(); > > /** >+ * Returns the meta object for the reference '{@link org.eclipse.tptp.wsdm.tooling.model.capabilities.Property#getMetrics <em>Metrics</em>}'. >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @return the meta object for the reference '<em>Metrics</em>'. >+ * @see org.eclipse.tptp.wsdm.tooling.model.capabilities.Property#getMetrics() >+ * @see #getProperty() >+ * @generated >+ */ >+ EReference getProperty_Metrics(); >+ >+ /** >+ * Returns the meta object for class '{@link org.eclipse.tptp.wsdm.tooling.model.capabilities.impl.MetadataDescriptor <em>Metadata</em>}'. >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @return the meta object for class '<em>Metadata</em>'. >+ * @see org.eclipse.tptp.wsdm.tooling.model.capabilities.impl.MetadataDescriptor >+ * @model instanceClass="org.eclipse.tptp.wsdm.tooling.model.capabilities.impl.MetadataDescriptor" >+ * @generated >+ */ >+ EClass getMetadata(); >+ >+ /** >+ * Returns the meta object for class '{@link org.eclipse.tptp.wsdm.tooling.model.capabilities.Metrics <em>Metrics</em>}'. >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @return the meta object for class '<em>Metrics</em>'. >+ * @see org.eclipse.tptp.wsdm.tooling.model.capabilities.Metrics >+ * @generated >+ */ >+ EClass getMetrics(); >+ >+ /** >+ * Returns the meta object for the attribute '{@link org.eclipse.tptp.wsdm.tooling.model.capabilities.Metrics#getChangeType <em>Change Type</em>}'. >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @return the meta object for the attribute '<em>Change Type</em>'. >+ * @see org.eclipse.tptp.wsdm.tooling.model.capabilities.Metrics#getChangeType() >+ * @see #getMetrics() >+ * @generated >+ */ >+ EAttribute getMetrics_ChangeType(); >+ >+ /** >+ * Returns the meta object for the attribute '{@link org.eclipse.tptp.wsdm.tooling.model.capabilities.Metrics#getTimeScope <em>Time Scope</em>}'. >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @return the meta object for the attribute '<em>Time Scope</em>'. >+ * @see org.eclipse.tptp.wsdm.tooling.model.capabilities.Metrics#getTimeScope() >+ * @see #getMetrics() >+ * @generated >+ */ >+ EAttribute getMetrics_TimeScope(); >+ >+ /** >+ * Returns the meta object for the attribute '{@link org.eclipse.tptp.wsdm.tooling.model.capabilities.Metrics#getGatheringTime <em>Gathering Time</em>}'. >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @return the meta object for the attribute '<em>Gathering Time</em>'. >+ * @see org.eclipse.tptp.wsdm.tooling.model.capabilities.Metrics#getGatheringTime() >+ * @see #getMetrics() >+ * @generated >+ */ >+ EAttribute getMetrics_GatheringTime(); >+ >+ /** >+ * Returns the meta object for the attribute '{@link org.eclipse.tptp.wsdm.tooling.model.capabilities.Metrics#getCalculationInterval <em>Calculation Interval</em>}'. >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @return the meta object for the attribute '<em>Calculation Interval</em>'. >+ * @see org.eclipse.tptp.wsdm.tooling.model.capabilities.Metrics#getCalculationInterval() >+ * @see #getMetrics() >+ * @generated >+ */ >+ EAttribute getMetrics_CalculationInterval(); >+ >+ /** > * Returns the factory that creates the instances of the model. > * <!-- begin-user-doc --> > * <!-- end-user-doc --> >@@ -582,7 +783,7 @@ > * <!-- end-user-doc --> > * @generated > */ >- interface Literals { >+ interface Literals { > /** > * The meta object literal for the '{@link org.eclipse.tptp.wsdm.tooling.model.capabilities.impl.CapabilityImpl <em>Capability</em>}' class. > * <!-- begin-user-doc --> >@@ -650,6 +851,22 @@ > EReference CAPABILITY__TOPIC_SPACES = eINSTANCE.getCapability_TopicSpaces(); > > /** >+ * The meta object literal for the '<em><b>Definition</b></em>' reference feature. >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated >+ */ >+ EReference CAPABILITY__DEFINITION = eINSTANCE.getCapability_Definition(); >+ >+ /** >+ * The meta object literal for the '<em><b>Metadata</b></em>' reference feature. >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated >+ */ >+ EReference CAPABILITY__METADATA = eINSTANCE.getCapability_Metadata(); >+ >+ /** > * The meta object literal for the '{@link org.eclipse.tptp.wsdm.tooling.model.capabilities.impl.TopicSpaceImpl <em>Topic Space</em>}' class. > * <!-- begin-user-doc --> > * <!-- end-user-doc --> >@@ -775,6 +992,66 @@ > */ > EReference PROPERTY__META_DATA = eINSTANCE.getProperty_MetaData(); > >+ /** >+ * The meta object literal for the '<em><b>Metrics</b></em>' reference feature. >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated >+ */ >+ EReference PROPERTY__METRICS = eINSTANCE.getProperty_Metrics(); >+ >+ /** >+ * The meta object literal for the '{@link org.eclipse.tptp.wsdm.tooling.model.capabilities.impl.MetadataDescriptor <em>Metadata</em>}' class. >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @see org.eclipse.tptp.wsdm.tooling.model.capabilities.impl.MetadataDescriptor >+ * @see org.eclipse.tptp.wsdm.tooling.model.capabilities.impl.CapabilitiesPackageImpl#getMetadata() >+ * @generated >+ */ >+ EClass METADATA = eINSTANCE.getMetadata(); >+ >+ /** >+ * The meta object literal for the '{@link org.eclipse.tptp.wsdm.tooling.model.capabilities.impl.MetricsImpl <em>Metrics</em>}' class. >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @see org.eclipse.tptp.wsdm.tooling.model.capabilities.impl.MetricsImpl >+ * @see org.eclipse.tptp.wsdm.tooling.model.capabilities.impl.CapabilitiesPackageImpl#getMetrics() >+ * @generated >+ */ >+ EClass METRICS = eINSTANCE.getMetrics(); >+ >+ /** >+ * The meta object literal for the '<em><b>Change Type</b></em>' attribute feature. >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated >+ */ >+ EAttribute METRICS__CHANGE_TYPE = eINSTANCE.getMetrics_ChangeType(); >+ >+ /** >+ * The meta object literal for the '<em><b>Time Scope</b></em>' attribute feature. >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated >+ */ >+ EAttribute METRICS__TIME_SCOPE = eINSTANCE.getMetrics_TimeScope(); >+ >+ /** >+ * The meta object literal for the '<em><b>Gathering Time</b></em>' attribute feature. >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated >+ */ >+ EAttribute METRICS__GATHERING_TIME = eINSTANCE.getMetrics_GatheringTime(); >+ >+ /** >+ * The meta object literal for the '<em><b>Calculation Interval</b></em>' attribute feature. >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated >+ */ >+ EAttribute METRICS__CALCULATION_INTERVAL = eINSTANCE.getMetrics_CalculationInterval(); >+ > } > > } //CapabilitiesPackage >Index: src/org/eclipse/tptp/wsdm/tooling/model/capabilities/Property.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.model/src/org/eclipse/tptp/wsdm/tooling/model/capabilities/Property.java,v >retrieving revision 1.7 >diff -u -r1.7 Property.java >--- src/org/eclipse/tptp/wsdm/tooling/model/capabilities/Property.java 13 Sep 2006 12:05:49 -0000 1.7 >+++ src/org/eclipse/tptp/wsdm/tooling/model/capabilities/Property.java 20 Jan 2007 13:34:05 -0000 >@@ -27,6 +27,7 @@ > * <ul> > * <li>{@link org.eclipse.tptp.wsdm.tooling.model.capabilities.Property#getElement <em>Element</em>}</li> > * <li>{@link org.eclipse.tptp.wsdm.tooling.model.capabilities.Property#getMetaData <em>Meta Data</em>}</li> >+ * <li>{@link org.eclipse.tptp.wsdm.tooling.model.capabilities.Property#getMetrics <em>Metrics</em>}</li> > * </ul> > * </p> > * >@@ -87,4 +88,30 @@ > */ > void setMetaData(PropertyType value); > >+ /** >+ * Returns the value of the '<em><b>Metrics</b></em>' reference. >+ * <!-- begin-user-doc --> >+ * <p> >+ * If the meaning of the '<em>Metrics</em>' reference isn't clear, >+ * there really should be more of a description here... >+ * </p> >+ * <!-- end-user-doc --> >+ * @return the value of the '<em>Metrics</em>' reference. >+ * @see #setMetrics(Metrics) >+ * @see org.eclipse.tptp.wsdm.tooling.model.capabilities.CapabilitiesPackage#getProperty_Metrics() >+ * @model >+ * @generated >+ */ >+ Metrics getMetrics(); >+ >+ /** >+ * Sets the value of the '{@link org.eclipse.tptp.wsdm.tooling.model.capabilities.Property#getMetrics <em>Metrics</em>}' reference. >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @param value the new value of the '<em>Metrics</em>' reference. >+ * @see #getMetrics() >+ * @generated >+ */ >+ void setMetrics(Metrics value); >+ > } // Property >Index: src/org/eclipse/tptp/wsdm/tooling/model/capabilities/CapabilitiesFactory.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.model/src/org/eclipse/tptp/wsdm/tooling/model/capabilities/CapabilitiesFactory.java,v >retrieving revision 1.7 >diff -u -r1.7 CapabilitiesFactory.java >--- src/org/eclipse/tptp/wsdm/tooling/model/capabilities/CapabilitiesFactory.java 13 Sep 2006 12:05:49 -0000 1.7 >+++ src/org/eclipse/tptp/wsdm/tooling/model/capabilities/CapabilitiesFactory.java 20 Jan 2007 13:34:04 -0000 >@@ -67,6 +67,15 @@ > Property createProperty(); > > /** >+ * Returns a new object of class '<em>Metrics</em>'. >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @return a new object of class '<em>Metrics</em>'. >+ * @generated >+ */ >+ Metrics createMetrics(); >+ >+ /** > * Returns the package supported by this factory. > * <!-- begin-user-doc --> > * <!-- end-user-doc --> >Index: src/org/eclipse/tptp/wsdm/tooling/model/capabilities/Capability.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.model/src/org/eclipse/tptp/wsdm/tooling/model/capabilities/Capability.java,v >retrieving revision 1.7 >diff -u -r1.7 Capability.java >--- src/org/eclipse/tptp/wsdm/tooling/model/capabilities/Capability.java 13 Sep 2006 12:05:49 -0000 1.7 >+++ src/org/eclipse/tptp/wsdm/tooling/model/capabilities/Capability.java 20 Jan 2007 13:34:05 -0000 >@@ -15,6 +15,10 @@ > > import org.eclipse.emf.ecore.EObject; > >+import org.eclipse.tptp.wsdm.tooling.model.capabilities.impl.MetadataDescriptor; >+ >+import org.eclipse.wst.wsdl.Definition; >+ > /** > * <!-- begin-user-doc --> > * A representation of the model object '<em><b>Capability</b></em>'. >@@ -30,6 +34,8 @@ > * <li>{@link org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability#getProperties <em>Properties</em>}</li> > * <li>{@link org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability#getOperations <em>Operations</em>}</li> > * <li>{@link org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability#getTopicSpaces <em>Topic Spaces</em>}</li> >+ * <li>{@link org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability#getDefinition <em>Definition</em>}</li> >+ * <li>{@link org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability#getMetadata <em>Metadata</em>}</li> > * </ul> > * </p> > * >@@ -190,4 +196,56 @@ > */ > EList getTopicSpaces(); > >+ /** >+ * Returns the value of the '<em><b>Definition</b></em>' reference. >+ * <!-- begin-user-doc --> >+ * <p> >+ * If the meaning of the '<em>Definition</em>' reference isn't clear, >+ * there really should be more of a description here... >+ * </p> >+ * <!-- end-user-doc --> >+ * @return the value of the '<em>Definition</em>' reference. >+ * @see #setDefinition(Definition) >+ * @see org.eclipse.tptp.wsdm.tooling.model.capabilities.CapabilitiesPackage#getCapability_Definition() >+ * @model >+ * @generated >+ */ >+ Definition getDefinition(); >+ >+ /** >+ * Sets the value of the '{@link org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability#getDefinition <em>Definition</em>}' reference. >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @param value the new value of the '<em>Definition</em>' reference. >+ * @see #getDefinition() >+ * @generated >+ */ >+ void setDefinition(Definition value); >+ >+ /** >+ * Returns the value of the '<em><b>Metadata</b></em>' reference. >+ * <!-- begin-user-doc --> >+ * <p> >+ * If the meaning of the '<em>Metadata</em>' reference isn't clear, >+ * there really should be more of a description here... >+ * </p> >+ * <!-- end-user-doc --> >+ * @return the value of the '<em>Metadata</em>' reference. >+ * @see #setMetadata(MetadataDescriptor) >+ * @see org.eclipse.tptp.wsdm.tooling.model.capabilities.CapabilitiesPackage#getCapability_Metadata() >+ * @model >+ * @generated >+ */ >+ MetadataDescriptor getMetadata(); >+ >+ /** >+ * Sets the value of the '{@link org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability#getMetadata <em>Metadata</em>}' reference. >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @param value the new value of the '<em>Metadata</em>' reference. >+ * @see #getMetadata() >+ * @generated >+ */ >+ void setMetadata(MetadataDescriptor value); >+ > } // Capability >Index: src/org/eclipse/tptp/wsdm/tooling/model/capabilities/impl/PropertyImpl.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.model/src/org/eclipse/tptp/wsdm/tooling/model/capabilities/impl/PropertyImpl.java,v >retrieving revision 1.7 >diff -u -r1.7 PropertyImpl.java >--- src/org/eclipse/tptp/wsdm/tooling/model/capabilities/impl/PropertyImpl.java 13 Sep 2006 12:05:50 -0000 1.7 >+++ src/org/eclipse/tptp/wsdm/tooling/model/capabilities/impl/PropertyImpl.java 20 Jan 2007 13:34:07 -0000 >@@ -20,6 +20,7 @@ > import org.eclipse.emf.ecore.impl.EObjectImpl; > > import org.eclipse.tptp.wsdm.tooling.model.capabilities.CapabilitiesPackage; >+import org.eclipse.tptp.wsdm.tooling.model.capabilities.Metrics; > import org.eclipse.tptp.wsdm.tooling.model.capabilities.Property; > > import org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.PropertyType; >@@ -35,6 +36,7 @@ > * <ul> > * <li>{@link org.eclipse.tptp.wsdm.tooling.model.capabilities.impl.PropertyImpl#getElement <em>Element</em>}</li> > * <li>{@link org.eclipse.tptp.wsdm.tooling.model.capabilities.impl.PropertyImpl#getMetaData <em>Meta Data</em>}</li> >+ * <li>{@link org.eclipse.tptp.wsdm.tooling.model.capabilities.impl.PropertyImpl#getMetrics <em>Metrics</em>}</li> > * </ul> > * </p> > * >@@ -62,6 +64,16 @@ > protected PropertyType metaData = null; > > /** >+ * The cached value of the '{@link #getMetrics() <em>Metrics</em>}' reference. >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @see #getMetrics() >+ * @generated >+ * @ordered >+ */ >+ protected Metrics metrics = null; >+ >+ /** > * <!-- begin-user-doc --> > * <!-- end-user-doc --> > * @generated >@@ -160,6 +172,44 @@ > * <!-- end-user-doc --> > * @generated > */ >+ public Metrics getMetrics() { >+ if (metrics != null && metrics.eIsProxy()) { >+ InternalEObject oldMetrics = (InternalEObject)metrics; >+ metrics = (Metrics)eResolveProxy(oldMetrics); >+ if (metrics != oldMetrics) { >+ if (eNotificationRequired()) >+ eNotify(new ENotificationImpl(this, Notification.RESOLVE, CapabilitiesPackage.PROPERTY__METRICS, oldMetrics, metrics)); >+ } >+ } >+ return metrics; >+ } >+ >+ /** >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated >+ */ >+ public Metrics basicGetMetrics() { >+ return metrics; >+ } >+ >+ /** >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated >+ */ >+ public void setMetrics(Metrics newMetrics) { >+ Metrics oldMetrics = metrics; >+ metrics = newMetrics; >+ if (eNotificationRequired()) >+ eNotify(new ENotificationImpl(this, Notification.SET, CapabilitiesPackage.PROPERTY__METRICS, oldMetrics, metrics)); >+ } >+ >+ /** >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated >+ */ > public Object eGet(int featureID, boolean resolve, boolean coreType) { > switch (featureID) { > case CapabilitiesPackage.PROPERTY__ELEMENT: >@@ -168,6 +218,9 @@ > case CapabilitiesPackage.PROPERTY__META_DATA: > if (resolve) return getMetaData(); > return basicGetMetaData(); >+ case CapabilitiesPackage.PROPERTY__METRICS: >+ if (resolve) return getMetrics(); >+ return basicGetMetrics(); > } > return super.eGet(featureID, resolve, coreType); > } >@@ -185,6 +238,9 @@ > case CapabilitiesPackage.PROPERTY__META_DATA: > setMetaData((PropertyType)newValue); > return; >+ case CapabilitiesPackage.PROPERTY__METRICS: >+ setMetrics((Metrics)newValue); >+ return; > } > super.eSet(featureID, newValue); > } >@@ -202,6 +258,9 @@ > case CapabilitiesPackage.PROPERTY__META_DATA: > setMetaData((PropertyType)null); > return; >+ case CapabilitiesPackage.PROPERTY__METRICS: >+ setMetrics((Metrics)null); >+ return; > } > super.eUnset(featureID); > } >@@ -217,6 +276,8 @@ > return element != null; > case CapabilitiesPackage.PROPERTY__META_DATA: > return metaData != null; >+ case CapabilitiesPackage.PROPERTY__METRICS: >+ return metrics != null; > } > return super.eIsSet(featureID); > } >Index: src/org/eclipse/tptp/wsdm/tooling/model/capabilities/impl/CapabilityImpl.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.model/src/org/eclipse/tptp/wsdm/tooling/model/capabilities/impl/CapabilityImpl.java,v >retrieving revision 1.7 >diff -u -r1.7 CapabilityImpl.java >--- src/org/eclipse/tptp/wsdm/tooling/model/capabilities/impl/CapabilityImpl.java 13 Sep 2006 12:05:50 -0000 1.7 >+++ src/org/eclipse/tptp/wsdm/tooling/model/capabilities/impl/CapabilityImpl.java 20 Jan 2007 13:34:07 -0000 >@@ -19,6 +19,9 @@ > > import org.eclipse.emf.ecore.EClass; > >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.emf.ecore.InternalEObject; >+ > import org.eclipse.emf.ecore.impl.ENotificationImpl; > import org.eclipse.emf.ecore.impl.EObjectImpl; > >@@ -29,6 +32,7 @@ > import org.eclipse.tptp.wsdm.tooling.model.capabilities.Property; > import org.eclipse.tptp.wsdm.tooling.model.capabilities.TopicSpace; > >+import org.eclipse.wst.wsdl.Definition; > import org.eclipse.wst.wsdl.Operation; > > /** >@@ -45,6 +49,8 @@ > * <li>{@link org.eclipse.tptp.wsdm.tooling.model.capabilities.impl.CapabilityImpl#getProperties <em>Properties</em>}</li> > * <li>{@link org.eclipse.tptp.wsdm.tooling.model.capabilities.impl.CapabilityImpl#getOperations <em>Operations</em>}</li> > * <li>{@link org.eclipse.tptp.wsdm.tooling.model.capabilities.impl.CapabilityImpl#getTopicSpaces <em>Topic Spaces</em>}</li> >+ * <li>{@link org.eclipse.tptp.wsdm.tooling.model.capabilities.impl.CapabilityImpl#getDefinition <em>Definition</em>}</li> >+ * <li>{@link org.eclipse.tptp.wsdm.tooling.model.capabilities.impl.CapabilityImpl#getMetadata <em>Metadata</em>}</li> > * </ul> > * </p> > * >@@ -162,6 +168,26 @@ > protected EList topicSpaces = null; > > /** >+ * The cached value of the '{@link #getDefinition() <em>Definition</em>}' reference. >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @see #getDefinition() >+ * @generated >+ * @ordered >+ */ >+ protected Definition definition = null; >+ >+ /** >+ * The cached value of the '{@link #getMetadata() <em>Metadata</em>}' reference. >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @see #getMetadata() >+ * @generated >+ * @ordered >+ */ >+ protected MetadataDescriptor metadata = null; >+ >+ /** > * <!-- begin-user-doc --> > * <!-- end-user-doc --> > * @generated >@@ -304,6 +330,82 @@ > * <!-- end-user-doc --> > * @generated > */ >+ public Definition getDefinition() { >+ if (definition != null && definition.eIsProxy()) { >+ InternalEObject oldDefinition = (InternalEObject)definition; >+ definition = (Definition)eResolveProxy(oldDefinition); >+ if (definition != oldDefinition) { >+ if (eNotificationRequired()) >+ eNotify(new ENotificationImpl(this, Notification.RESOLVE, CapabilitiesPackage.CAPABILITY__DEFINITION, oldDefinition, definition)); >+ } >+ } >+ return definition; >+ } >+ >+ /** >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated >+ */ >+ public Definition basicGetDefinition() { >+ return definition; >+ } >+ >+ /** >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated >+ */ >+ public void setDefinition(Definition newDefinition) { >+ Definition oldDefinition = definition; >+ definition = newDefinition; >+ if (eNotificationRequired()) >+ eNotify(new ENotificationImpl(this, Notification.SET, CapabilitiesPackage.CAPABILITY__DEFINITION, oldDefinition, definition)); >+ } >+ >+ /** >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated NOT >+ */ >+ public MetadataDescriptor getMetadata() { >+ /*if (metadata != null && ((EObject)metadata).eIsProxy()) { >+ InternalEObject oldMetadata = (InternalEObject)metadata; >+ metadata = (MetadataDescriptor)eResolveProxy(oldMetadata); >+ if (metadata != oldMetadata) { >+ if (eNotificationRequired()) >+ eNotify(new ENotificationImpl(this, Notification.RESOLVE, CapabilitiesPackage.CAPABILITY__METADATA, oldMetadata, metadata)); >+ } >+ }*/ >+ return metadata; >+ } >+ >+ /** >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated >+ */ >+ public MetadataDescriptor basicGetMetadata() { >+ return metadata; >+ } >+ >+ /** >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated >+ */ >+ public void setMetadata(MetadataDescriptor newMetadata) { >+ MetadataDescriptor oldMetadata = metadata; >+ metadata = newMetadata; >+ if (eNotificationRequired()) >+ eNotify(new ENotificationImpl(this, Notification.SET, CapabilitiesPackage.CAPABILITY__METADATA, oldMetadata, metadata)); >+ } >+ >+ /** >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated >+ */ > public Object eGet(int featureID, boolean resolve, boolean coreType) { > switch (featureID) { > case CapabilitiesPackage.CAPABILITY__DESCRIPTION: >@@ -320,6 +422,12 @@ > return getOperations(); > case CapabilitiesPackage.CAPABILITY__TOPIC_SPACES: > return getTopicSpaces(); >+ case CapabilitiesPackage.CAPABILITY__DEFINITION: >+ if (resolve) return getDefinition(); >+ return basicGetDefinition(); >+ case CapabilitiesPackage.CAPABILITY__METADATA: >+ if (resolve) return getMetadata(); >+ return basicGetMetadata(); > } > return super.eGet(featureID, resolve, coreType); > } >@@ -355,6 +463,12 @@ > getTopicSpaces().clear(); > getTopicSpaces().addAll((Collection)newValue); > return; >+ case CapabilitiesPackage.CAPABILITY__DEFINITION: >+ setDefinition((Definition)newValue); >+ return; >+ case CapabilitiesPackage.CAPABILITY__METADATA: >+ setMetadata((MetadataDescriptor)newValue); >+ return; > } > super.eSet(featureID, newValue); > } >@@ -387,6 +501,12 @@ > case CapabilitiesPackage.CAPABILITY__TOPIC_SPACES: > getTopicSpaces().clear(); > return; >+ case CapabilitiesPackage.CAPABILITY__DEFINITION: >+ setDefinition((Definition)null); >+ return; >+ case CapabilitiesPackage.CAPABILITY__METADATA: >+ setMetadata((MetadataDescriptor)null); >+ return; > } > super.eUnset(featureID); > } >@@ -412,6 +532,10 @@ > return operations != null && !operations.isEmpty(); > case CapabilitiesPackage.CAPABILITY__TOPIC_SPACES: > return topicSpaces != null && !topicSpaces.isEmpty(); >+ case CapabilitiesPackage.CAPABILITY__DEFINITION: >+ return definition != null; >+ case CapabilitiesPackage.CAPABILITY__METADATA: >+ return metadata != null; > } > return super.eIsSet(featureID); > } >Index: src/org/eclipse/tptp/wsdm/tooling/model/capabilities/impl/CapabilitiesPackageImpl.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.model/src/org/eclipse/tptp/wsdm/tooling/model/capabilities/impl/CapabilitiesPackageImpl.java,v >retrieving revision 1.7 >diff -u -r1.7 CapabilitiesPackageImpl.java >--- src/org/eclipse/tptp/wsdm/tooling/model/capabilities/impl/CapabilitiesPackageImpl.java 13 Sep 2006 12:05:50 -0000 1.7 >+++ src/org/eclipse/tptp/wsdm/tooling/model/capabilities/impl/CapabilitiesPackageImpl.java 20 Jan 2007 13:34:06 -0000 >@@ -30,6 +30,7 @@ > import org.eclipse.tptp.wsdm.tooling.model.capabilities.CapabilitiesFactory; > import org.eclipse.tptp.wsdm.tooling.model.capabilities.CapabilitiesPackage; > import org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability; >+import org.eclipse.tptp.wsdm.tooling.model.capabilities.Metrics; > import org.eclipse.tptp.wsdm.tooling.model.capabilities.Property; > import org.eclipse.tptp.wsdm.tooling.model.capabilities.Topic; > import org.eclipse.tptp.wsdm.tooling.model.capabilities.TopicSpace; >@@ -90,6 +91,20 @@ > private EClass propertyEClass = null; > > /** >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated >+ */ >+ private EClass metadataEClass = null; >+ >+ /** >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated >+ */ >+ private EClass metricsEClass = null; >+ >+ /** > * Creates an instance of the model <b>Package</b>, registered with > * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package > * package URI value. >@@ -259,6 +274,24 @@ > * <!-- end-user-doc --> > * @generated > */ >+ public EReference getCapability_Definition() { >+ return (EReference)capabilityEClass.getEStructuralFeatures().get(7); >+ } >+ >+ /** >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated >+ */ >+ public EReference getCapability_Metadata() { >+ return (EReference)capabilityEClass.getEStructuralFeatures().get(8); >+ } >+ >+ /** >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated >+ */ > public EClass getTopicSpace() { > return topicSpaceEClass; > } >@@ -394,6 +427,69 @@ > * <!-- end-user-doc --> > * @generated > */ >+ public EReference getProperty_Metrics() { >+ return (EReference)propertyEClass.getEStructuralFeatures().get(2); >+ } >+ >+ /** >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated >+ */ >+ public EClass getMetadata() { >+ return metadataEClass; >+ } >+ >+ /** >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated >+ */ >+ public EClass getMetrics() { >+ return metricsEClass; >+ } >+ >+ /** >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated >+ */ >+ public EAttribute getMetrics_ChangeType() { >+ return (EAttribute)metricsEClass.getEStructuralFeatures().get(0); >+ } >+ >+ /** >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated >+ */ >+ public EAttribute getMetrics_TimeScope() { >+ return (EAttribute)metricsEClass.getEStructuralFeatures().get(1); >+ } >+ >+ /** >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated >+ */ >+ public EAttribute getMetrics_GatheringTime() { >+ return (EAttribute)metricsEClass.getEStructuralFeatures().get(2); >+ } >+ >+ /** >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated >+ */ >+ public EAttribute getMetrics_CalculationInterval() { >+ return (EAttribute)metricsEClass.getEStructuralFeatures().get(3); >+ } >+ >+ /** >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated >+ */ > public CapabilitiesFactory getCapabilitiesFactory() { > return (CapabilitiesFactory)getEFactoryInstance(); > } >@@ -425,6 +521,8 @@ > createEReference(capabilityEClass, CAPABILITY__PROPERTIES); > createEReference(capabilityEClass, CAPABILITY__OPERATIONS); > createEReference(capabilityEClass, CAPABILITY__TOPIC_SPACES); >+ createEReference(capabilityEClass, CAPABILITY__DEFINITION); >+ createEReference(capabilityEClass, CAPABILITY__METADATA); > > topicSpaceEClass = createEClass(TOPIC_SPACE); > createEAttribute(topicSpaceEClass, TOPIC_SPACE__NAME); >@@ -443,6 +541,15 @@ > propertyEClass = createEClass(PROPERTY); > createEReference(propertyEClass, PROPERTY__ELEMENT); > createEReference(propertyEClass, PROPERTY__META_DATA); >+ createEReference(propertyEClass, PROPERTY__METRICS); >+ >+ metadataEClass = createEClass(METADATA); >+ >+ metricsEClass = createEClass(METRICS); >+ createEAttribute(metricsEClass, METRICS__CHANGE_TYPE); >+ createEAttribute(metricsEClass, METRICS__TIME_SCOPE); >+ createEAttribute(metricsEClass, METRICS__GATHERING_TIME); >+ createEAttribute(metricsEClass, METRICS__CALCULATION_INTERVAL); > } > > /** >@@ -484,6 +591,8 @@ > initEReference(getCapability_Properties(), this.getProperty(), null, "properties", null, 0, -1, Capability.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); > initEReference(getCapability_Operations(), theWSDLPackage.getOperation(), null, "operations", null, 0, -1, Capability.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); > initEReference(getCapability_TopicSpaces(), this.getTopicSpace(), null, "topicSpaces", null, 0, -1, Capability.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); >+ initEReference(getCapability_Definition(), theWSDLPackage.getDefinition(), null, "definition", null, 0, 1, Capability.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); >+ initEReference(getCapability_Metadata(), this.getMetadata(), null, "metadata", null, 0, 1, Capability.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); > > initEClass(topicSpaceEClass, TopicSpace.class, "TopicSpace", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); > initEAttribute(getTopicSpace_Name(), ecorePackage.getEString(), "name", null, 0, 1, TopicSpace.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); >@@ -502,6 +611,15 @@ > initEClass(propertyEClass, Property.class, "Property", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); > initEReference(getProperty_Element(), theXSDPackage.getXSDElementDeclaration(), null, "element", null, 0, 1, Property.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); > initEReference(getProperty_MetaData(), theMetadataDescriptorPackage.getPropertyType(), null, "metaData", null, 0, 1, Property.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); >+ initEReference(getProperty_Metrics(), this.getMetrics(), null, "metrics", null, 0, 1, Property.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); >+ >+ initEClass(metadataEClass, MetadataDescriptor.class, "Metadata", IS_ABSTRACT, IS_INTERFACE, !IS_GENERATED_INSTANCE_CLASS); >+ >+ initEClass(metricsEClass, Metrics.class, "Metrics", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); >+ initEAttribute(getMetrics_ChangeType(), ecorePackage.getEString(), "changeType", null, 0, 1, Metrics.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); >+ initEAttribute(getMetrics_TimeScope(), ecorePackage.getEString(), "timeScope", null, 0, 1, Metrics.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); >+ initEAttribute(getMetrics_GatheringTime(), ecorePackage.getEString(), "gatheringTime", null, 0, 1, Metrics.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); >+ initEAttribute(getMetrics_CalculationInterval(), ecorePackage.getEString(), "calculationInterval", null, 0, 1, Metrics.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); > > // Create resource > createResource(eNS_URI); >Index: src/org/eclipse/tptp/wsdm/tooling/model/capabilities/impl/CapabilitiesFactoryImpl.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.model/src/org/eclipse/tptp/wsdm/tooling/model/capabilities/impl/CapabilitiesFactoryImpl.java,v >retrieving revision 1.7 >diff -u -r1.7 CapabilitiesFactoryImpl.java >--- src/org/eclipse/tptp/wsdm/tooling/model/capabilities/impl/CapabilitiesFactoryImpl.java 13 Sep 2006 12:05:50 -0000 1.7 >+++ src/org/eclipse/tptp/wsdm/tooling/model/capabilities/impl/CapabilitiesFactoryImpl.java 20 Jan 2007 13:34:05 -0000 >@@ -68,6 +68,7 @@ > case CapabilitiesPackage.TOPIC_SPACE: return createTopicSpace(); > case CapabilitiesPackage.TOPIC: return createTopic(); > case CapabilitiesPackage.PROPERTY: return createProperty(); >+ case CapabilitiesPackage.METRICS: return createMetrics(); > default: > throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); > } >@@ -118,6 +119,16 @@ > * <!-- end-user-doc --> > * @generated > */ >+ public Metrics createMetrics() { >+ MetricsImpl metrics = new MetricsImpl(); >+ return metrics; >+ } >+ >+ /** >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated >+ */ > public CapabilitiesPackage getCapabilitiesPackage() { > return (CapabilitiesPackage)getEPackage(); > } >Index: model/capabilities.ecore >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.model/model/capabilities.ecore,v >retrieving revision 1.2 >diff -u -r1.2 capabilities.ecore >--- model/capabilities.ecore 12 Sep 2006 13:47:00 -0000 1.2 >+++ model/capabilities.ecore 20 Jan 2007 13:34:01 -0000 >@@ -14,6 +14,8 @@ > eType="ecore:EClass wsdl.ecore#//Operation"/> > <eStructuralFeatures xsi:type="ecore:EReference" name="topicSpaces" upperBound="-1" > eType="#//TopicSpace"/> >+ <eStructuralFeatures xsi:type="ecore:EReference" name="definition" eType="ecore:EClass wsdl.ecore#//Definition"/> >+ <eStructuralFeatures xsi:type="ecore:EReference" name="metadata" eType="#//Metadata"/> > </eClassifiers> > <eClassifiers xsi:type="ecore:EClass" name="TopicSpace"> > <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> >@@ -36,5 +38,14 @@ > <eClassifiers xsi:type="ecore:EClass" name="Property"> > <eStructuralFeatures xsi:type="ecore:EReference" name="element" eType="ecore:EClass ../../../plugin/org.eclipse.xsd/model/XSD.ecore#//XSDElementDeclaration"/> > <eStructuralFeatures xsi:type="ecore:EReference" name="metaData" eType="ecore:EClass metadataDescriptor.ecore#//PropertyType"/> >+ <eStructuralFeatures xsi:type="ecore:EReference" name="metrics" eType="#//Metrics"/> >+ </eClassifiers> >+ <eClassifiers xsi:type="ecore:EClass" name="Metadata" instanceClassName="org.eclipse.tptp.wsdm.tooling.model.capabilities.impl.MetadataDescriptor" >+ interface="true"/> >+ <eClassifiers xsi:type="ecore:EClass" name="Metrics"> >+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="changeType" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> >+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="timeScope" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> >+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="gatheringTime" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> >+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="calculationInterval" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> > </eClassifiers> > </ecore:EPackage> >Index: model/metadataDescriptor.ecore >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.model/model/metadataDescriptor.ecore,v >retrieving revision 1.1 >diff -u -r1.1 metadataDescriptor.ecore >--- model/metadataDescriptor.ecore 12 Sep 2006 13:47:00 -0000 1.1 >+++ model/metadataDescriptor.ecore 20 Jan 2007 13:34:02 -0000 >@@ -283,7 +283,7 @@ > </eAnnotations> > </eStructuralFeatures> > <eStructuralFeatures xsi:type="ecore:EAttribute" name="interface" unique="false" >- lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2003/XMLType#//QName"> >+ lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2003/XMLType#//NCName"> > <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData"> > <details key="kind" value="attribute"/> > <details key="name" value="interface"/> >@@ -297,7 +297,7 @@ > </eAnnotations> > </eStructuralFeatures> > <eStructuralFeatures xsi:type="ecore:EAttribute" name="wsdlLocation" unique="false" >- eType="#//PairsOfURIType"> >+ eType="ecore:EDataType http://www.eclipse.org/emf/2003/XMLType#//String"> > <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData"> > <details key="kind" value="attribute"/> > <details key="name" value="wsdlLocation"/> >@@ -407,7 +407,7 @@ > </eAnnotations> > </eStructuralFeatures> > <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" unique="false" lowerBound="1" >- eType="ecore:EDataType http://www.eclipse.org/emf/2003/XMLType#//QName"> >+ eType="ecore:EDataType http://www.eclipse.org/emf/2003/XMLType#//NCName"> > <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData"> > <details key="kind" value="attribute"/> > <details key="name" value="name"/> >@@ -565,4 +565,7 @@ > </eAnnotations> > </eStructuralFeatures> > </eClassifiers> >+ <eClassifiers xsi:type="ecore:EClass" name="Metrics"> >+ <eStructuralFeatures xsi:type="ecore:EReference" name="changeType"/> >+ </eClassifiers> > </ecore:EPackage> >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.model/META-INF/MANIFEST.MF,v >retrieving revision 1.3 >diff -u -r1.3 MANIFEST.MF >--- META-INF/MANIFEST.MF 20 Sep 2006 14:17:26 -0000 1.3 >+++ META-INF/MANIFEST.MF 20 Jan 2007 13:34:01 -0000 >@@ -9,8 +9,9 @@ > org.eclipse.emf.ecore;visibility:=reexport, > org.eclipse.emf.ecore.xmi;visibility:=reexport, > org.eclipse.xsd;visibility:=reexport, >- org.eclipse.wst.wsdl;visibility:=reexport, >- org.eclipse.core.resources >+ org.eclipse.core.resources, >+ org.wsdl4j, >+ org.eclipse.wst.wsdl;visibility:=reexport > Eclipse-LazyStart: true > Export-Package: org.apache.ws.muse.descriptor, > org.apache.ws.muse.descriptor.impl, >Index: src/org/eclipse/tptp/wsdm/tooling/model/capabilities/impl/MetricsImpl.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/model/capabilities/impl/MetricsImpl.java >diff -N src/org/eclipse/tptp/wsdm/tooling/model/capabilities/impl/MetricsImpl.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/model/capabilities/impl/MetricsImpl.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,328 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Balan Subramanian (bsubram@us.ibm.com) >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.tptp.wsdm.tooling.model.capabilities.impl; >+ >+import org.eclipse.emf.common.notify.Notification; >+ >+import org.eclipse.emf.ecore.EClass; >+ >+import org.eclipse.emf.ecore.impl.ENotificationImpl; >+import org.eclipse.emf.ecore.impl.EObjectImpl; >+ >+import org.eclipse.tptp.wsdm.tooling.model.capabilities.CapabilitiesPackage; >+import org.eclipse.tptp.wsdm.tooling.model.capabilities.Metrics; >+ >+/** >+ * <!-- begin-user-doc --> >+ * An implementation of the model object '<em><b>Metrics</b></em>'. >+ * <!-- end-user-doc --> >+ * <p> >+ * The following features are implemented: >+ * <ul> >+ * <li>{@link org.eclipse.tptp.wsdm.tooling.model.capabilities.impl.MetricsImpl#getChangeType <em>Change Type</em>}</li> >+ * <li>{@link org.eclipse.tptp.wsdm.tooling.model.capabilities.impl.MetricsImpl#getTimeScope <em>Time Scope</em>}</li> >+ * <li>{@link org.eclipse.tptp.wsdm.tooling.model.capabilities.impl.MetricsImpl#getGatheringTime <em>Gathering Time</em>}</li> >+ * <li>{@link org.eclipse.tptp.wsdm.tooling.model.capabilities.impl.MetricsImpl#getCalculationInterval <em>Calculation Interval</em>}</li> >+ * </ul> >+ * </p> >+ * >+ * @generated >+ */ >+public class MetricsImpl extends EObjectImpl implements Metrics { >+ /** >+ * The default value of the '{@link #getChangeType() <em>Change Type</em>}' attribute. >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @see #getChangeType() >+ * @generated >+ * @ordered >+ */ >+ protected static final String CHANGE_TYPE_EDEFAULT = null; >+ >+ /** >+ * The cached value of the '{@link #getChangeType() <em>Change Type</em>}' attribute. >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @see #getChangeType() >+ * @generated >+ * @ordered >+ */ >+ protected String changeType = CHANGE_TYPE_EDEFAULT; >+ >+ /** >+ * The default value of the '{@link #getTimeScope() <em>Time Scope</em>}' attribute. >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @see #getTimeScope() >+ * @generated >+ * @ordered >+ */ >+ protected static final String TIME_SCOPE_EDEFAULT = null; >+ >+ /** >+ * The cached value of the '{@link #getTimeScope() <em>Time Scope</em>}' attribute. >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @see #getTimeScope() >+ * @generated >+ * @ordered >+ */ >+ protected String timeScope = TIME_SCOPE_EDEFAULT; >+ >+ /** >+ * The default value of the '{@link #getGatheringTime() <em>Gathering Time</em>}' attribute. >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @see #getGatheringTime() >+ * @generated >+ * @ordered >+ */ >+ protected static final String GATHERING_TIME_EDEFAULT = null; >+ >+ /** >+ * The cached value of the '{@link #getGatheringTime() <em>Gathering Time</em>}' attribute. >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @see #getGatheringTime() >+ * @generated >+ * @ordered >+ */ >+ protected String gatheringTime = GATHERING_TIME_EDEFAULT; >+ >+ /** >+ * The default value of the '{@link #getCalculationInterval() <em>Calculation Interval</em>}' attribute. >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @see #getCalculationInterval() >+ * @generated >+ * @ordered >+ */ >+ protected static final String CALCULATION_INTERVAL_EDEFAULT = null; >+ >+ /** >+ * The cached value of the '{@link #getCalculationInterval() <em>Calculation Interval</em>}' attribute. >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @see #getCalculationInterval() >+ * @generated >+ * @ordered >+ */ >+ protected String calculationInterval = CALCULATION_INTERVAL_EDEFAULT; >+ >+ /** >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated >+ */ >+ protected MetricsImpl() { >+ super(); >+ } >+ >+ /** >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated >+ */ >+ protected EClass eStaticClass() { >+ return CapabilitiesPackage.Literals.METRICS; >+ } >+ >+ /** >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated >+ */ >+ public String getChangeType() { >+ return changeType; >+ } >+ >+ /** >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated >+ */ >+ public void setChangeType(String newChangeType) { >+ String oldChangeType = changeType; >+ changeType = newChangeType; >+ if (eNotificationRequired()) >+ eNotify(new ENotificationImpl(this, Notification.SET, CapabilitiesPackage.METRICS__CHANGE_TYPE, oldChangeType, changeType)); >+ } >+ >+ /** >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated >+ */ >+ public String getTimeScope() { >+ return timeScope; >+ } >+ >+ /** >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated >+ */ >+ public void setTimeScope(String newTimeScope) { >+ String oldTimeScope = timeScope; >+ timeScope = newTimeScope; >+ if (eNotificationRequired()) >+ eNotify(new ENotificationImpl(this, Notification.SET, CapabilitiesPackage.METRICS__TIME_SCOPE, oldTimeScope, timeScope)); >+ } >+ >+ /** >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated >+ */ >+ public String getGatheringTime() { >+ return gatheringTime; >+ } >+ >+ /** >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated >+ */ >+ public void setGatheringTime(String newGatheringTime) { >+ String oldGatheringTime = gatheringTime; >+ gatheringTime = newGatheringTime; >+ if (eNotificationRequired()) >+ eNotify(new ENotificationImpl(this, Notification.SET, CapabilitiesPackage.METRICS__GATHERING_TIME, oldGatheringTime, gatheringTime)); >+ } >+ >+ /** >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated >+ */ >+ public String getCalculationInterval() { >+ return calculationInterval; >+ } >+ >+ /** >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated >+ */ >+ public void setCalculationInterval(String newCalculationInterval) { >+ String oldCalculationInterval = calculationInterval; >+ calculationInterval = newCalculationInterval; >+ if (eNotificationRequired()) >+ eNotify(new ENotificationImpl(this, Notification.SET, CapabilitiesPackage.METRICS__CALCULATION_INTERVAL, oldCalculationInterval, calculationInterval)); >+ } >+ >+ /** >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated >+ */ >+ public Object eGet(int featureID, boolean resolve, boolean coreType) { >+ switch (featureID) { >+ case CapabilitiesPackage.METRICS__CHANGE_TYPE: >+ return getChangeType(); >+ case CapabilitiesPackage.METRICS__TIME_SCOPE: >+ return getTimeScope(); >+ case CapabilitiesPackage.METRICS__GATHERING_TIME: >+ return getGatheringTime(); >+ case CapabilitiesPackage.METRICS__CALCULATION_INTERVAL: >+ return getCalculationInterval(); >+ } >+ return super.eGet(featureID, resolve, coreType); >+ } >+ >+ /** >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated >+ */ >+ public void eSet(int featureID, Object newValue) { >+ switch (featureID) { >+ case CapabilitiesPackage.METRICS__CHANGE_TYPE: >+ setChangeType((String)newValue); >+ return; >+ case CapabilitiesPackage.METRICS__TIME_SCOPE: >+ setTimeScope((String)newValue); >+ return; >+ case CapabilitiesPackage.METRICS__GATHERING_TIME: >+ setGatheringTime((String)newValue); >+ return; >+ case CapabilitiesPackage.METRICS__CALCULATION_INTERVAL: >+ setCalculationInterval((String)newValue); >+ return; >+ } >+ super.eSet(featureID, newValue); >+ } >+ >+ /** >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated >+ */ >+ public void eUnset(int featureID) { >+ switch (featureID) { >+ case CapabilitiesPackage.METRICS__CHANGE_TYPE: >+ setChangeType(CHANGE_TYPE_EDEFAULT); >+ return; >+ case CapabilitiesPackage.METRICS__TIME_SCOPE: >+ setTimeScope(TIME_SCOPE_EDEFAULT); >+ return; >+ case CapabilitiesPackage.METRICS__GATHERING_TIME: >+ setGatheringTime(GATHERING_TIME_EDEFAULT); >+ return; >+ case CapabilitiesPackage.METRICS__CALCULATION_INTERVAL: >+ setCalculationInterval(CALCULATION_INTERVAL_EDEFAULT); >+ return; >+ } >+ super.eUnset(featureID); >+ } >+ >+ /** >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated >+ */ >+ public boolean eIsSet(int featureID) { >+ switch (featureID) { >+ case CapabilitiesPackage.METRICS__CHANGE_TYPE: >+ return CHANGE_TYPE_EDEFAULT == null ? changeType != null : !CHANGE_TYPE_EDEFAULT.equals(changeType); >+ case CapabilitiesPackage.METRICS__TIME_SCOPE: >+ return TIME_SCOPE_EDEFAULT == null ? timeScope != null : !TIME_SCOPE_EDEFAULT.equals(timeScope); >+ case CapabilitiesPackage.METRICS__GATHERING_TIME: >+ return GATHERING_TIME_EDEFAULT == null ? gatheringTime != null : !GATHERING_TIME_EDEFAULT.equals(gatheringTime); >+ case CapabilitiesPackage.METRICS__CALCULATION_INTERVAL: >+ return CALCULATION_INTERVAL_EDEFAULT == null ? calculationInterval != null : !CALCULATION_INTERVAL_EDEFAULT.equals(calculationInterval); >+ } >+ return super.eIsSet(featureID); >+ } >+ >+ /** >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated >+ */ >+ public String toString() { >+ if (eIsProxy()) return super.toString(); >+ >+ StringBuffer result = new StringBuffer(super.toString()); >+ result.append(" (changeType: "); >+ result.append(changeType); >+ result.append(", timeScope: "); >+ result.append(timeScope); >+ result.append(", gatheringTime: "); >+ result.append(gatheringTime); >+ result.append(", calculationInterval: "); >+ result.append(calculationInterval); >+ result.append(')'); >+ return result.toString(); >+ } >+ >+} //MetricsImpl >Index: src/org/eclipse/tptp/wsdm/tooling/model/capabilities/impl/TopicSpace2MetaDataDescriptor.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/model/capabilities/impl/TopicSpace2MetaDataDescriptor.java >diff -N src/org/eclipse/tptp/wsdm/tooling/model/capabilities/impl/TopicSpace2MetaDataDescriptor.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/model/capabilities/impl/TopicSpace2MetaDataDescriptor.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,166 @@ >+/******************************************************************************* >+ * 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.model.capabilities.impl; >+ >+import java.util.ArrayList; >+import java.util.Iterator; >+import java.util.List; >+ >+import org.eclipse.emf.common.util.EMap; >+import org.eclipse.tptp.wsdm.tooling.model.capabilities.Topic; >+import org.eclipse.tptp.wsdm.tooling.model.capabilities.TopicSpace; >+ >+/** >+ * Generate a topic expression for each topic available in capability.<br> >+ * So if capability has topics defined as<br> >+ * <br> >+ * http://w3.ibm.com/capabilities/WAS (TopicNameSpace)<br> >+ * |____RootTopic <br> >+ * |______ChildTopic <br> >+ * <br> >+ * >+ * Then it will generate the following topic expressions in RMD<br> >+ * <br> >+ * >+ * xmlns:topics1="http://w3.ibm.com/capabilities/WAS/Topics"<br> >+ * >+ * < wsnt:TopicExpression > topics1:RootTopic < /wsnt:TopicExpression >+ * ><br> >+ * < wsnt:TopicExpression > topics1:RootTopic/ChildTopic < >+ * /wsnt:TopicExpression ><br> >+ * >+ * @see #getTopicExpressions() >+ * >+ */ >+ >+public class TopicSpace2MetaDataDescriptor >+{ >+ >+ private List _topicSpaces; >+ >+ private List _generatedTopicExpressions; >+ >+ private EMap _nsMap; >+ >+ /** >+ * Creates the instance of this class. >+ */ >+ public TopicSpace2MetaDataDescriptor(EMap nsMap, List topicSpaces) >+ { >+ _topicSpaces = topicSpaces; >+ _nsMap = nsMap; >+ _generatedTopicExpressions = new ArrayList(); >+ } >+ >+ /** >+ * >+ * @return Topic expression. >+ */ >+ public String[] getTopicExpressions() >+ { >+ for (int i = 0; i < _topicSpaces.size(); i++) >+ { >+ TopicSpace topicSpace = (TopicSpace) _topicSpaces.get(i); >+ visitTopicSpace(topicSpace); >+ } >+ return (String[]) _generatedTopicExpressions.toArray(new String[0]); >+ } >+ >+ private void visitTopicSpace(TopicSpace topicSpace) >+ { >+ String prefix = getPrefix(topicSpace.getNamespace()); >+ for (int i = 0; i < topicSpace.getRootTopics().size(); i++) >+ { >+ visitRootTopic((Topic) topicSpace.getRootTopics().get(i), prefix); >+ } >+ } >+ >+ private void visitRootTopic(Topic rootTopic, String prefix) >+ { >+ String topicExpression = prepareExpression(prefix, rootTopic); >+ if (!_generatedTopicExpressions.contains(topicExpression)) >+ _generatedTopicExpressions.add(topicExpression); >+ >+ for (int i = 0; i < rootTopic.getChildren().size(); i++) >+ { >+ visitTopic((Topic) rootTopic.getChildren().get(i), prefix); >+ } >+ } >+ >+ private void visitTopic(Topic topic, String prefix) >+ { >+ String topicExpression = prepareExpression(prefix, topic); >+ if (!_generatedTopicExpressions.contains(topicExpression)) >+ _generatedTopicExpressions.add(topicExpression); >+ >+ for (int i = 0; i < topic.getChildren().size(); i++) >+ { >+ visitTopic((Topic) topic.getChildren().get(i), prefix); >+ } >+ } >+ >+ private String prepareExpression(String prefix, Topic topic) >+ { >+ StringBuffer buffer = new StringBuffer(); >+ buffer.append(topic.getName()); >+ while (topic.getParent() != null) >+ { >+ topic = topic.getParent(); >+ buffer.insert(0, topic.getName() + "/"); >+ } >+ buffer.insert(0, prefix + ":"); >+ return buffer.toString(); >+ } >+ >+ private String getPrefix(String ns) >+ { >+ Iterator keyIt = _nsMap.keySet().iterator(); >+ Iterator valueIt = _nsMap.values().iterator(); >+ while (keyIt.hasNext()) >+ { >+ String prefix = (String) keyIt.next(); >+ String namespace = (String) valueIt.next(); >+ if (namespace.equals(ns)) >+ return prefix; >+ } >+ >+ String newPrefix = generateNewPrefix(); >+ _nsMap.put(newPrefix, ns); >+ return newPrefix; >+ } >+ >+ private String generateNewPrefix() >+ { >+ int counter = 1; >+ String newPrefix = "topics" + counter; >+ while (isPrefixExists(newPrefix)) >+ { >+ counter++; >+ newPrefix = "topics" + counter; >+ } >+ return newPrefix; >+ } >+ >+ private boolean isPrefixExists(String prefix) >+ { >+ Iterator keyIt = _nsMap.keySet().iterator(); >+ while (keyIt.hasNext()) >+ { >+ String pfx = (String) keyIt.next(); >+ if (pfx.equals(prefix)) >+ return true; >+ } >+ return false; >+ } >+ >+} >Index: src/org/eclipse/tptp/wsdm/tooling/model/capabilities/impl/MetaDataDescriptor2TopicSpace.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/model/capabilities/impl/MetaDataDescriptor2TopicSpace.java >diff -N src/org/eclipse/tptp/wsdm/tooling/model/capabilities/impl/MetaDataDescriptor2TopicSpace.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/model/capabilities/impl/MetaDataDescriptor2TopicSpace.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,215 @@ >+/******************************************************************************* >+ * 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.model.capabilities.impl; >+ >+import java.util.ArrayList; >+import java.util.List; >+import java.util.StringTokenizer; >+ >+import org.eclipse.emf.common.util.EMap; >+import org.eclipse.tptp.wsdm.tooling.model.capabilities.CapabilitiesFactory; >+import org.eclipse.tptp.wsdm.tooling.model.capabilities.Topic; >+import org.eclipse.tptp.wsdm.tooling.model.capabilities.TopicSpace; >+ >+/** >+ * >+ * Populate capability topics from TopicExpression property.<br> >+ * If RMD file has TopicExpression defined as <br> >+ * <br> >+ * >+ * xmlns:topics1="http://w3.ibm.com/capabilities/WAS/Topics"<br> >+ * >+ * < wsnt:TopicExpression > topics1:RootTopic < /wsnt:TopicExpression >+ * ><br> >+ * < wsnt:TopicExpression > topics1:RootTopic/ChildTopic < >+ * /wsnt:TopicExpression ><br> >+ * <br> >+ * >+ * Then it will create in memory model for topics as<br> >+ * <br> >+ * >+ * http://w3.ibm.com/capabilities/WAS (TopicNameSpace)<br> >+ * |____RootTopic <br> >+ * |______ChildTopic <br> >+ * <br> >+ * >+ * @see #getTopicSpaces() >+ * >+ */ >+ >+public class MetaDataDescriptor2TopicSpace >+{ >+ >+ private List _topicSpaces; >+ >+ private EMap _nsMap; >+ >+ /** >+ * Creates the object of this class.<br> >+ * Parameter passed is the map of the namespaces available in rmd file. >+ */ >+ public MetaDataDescriptor2TopicSpace(EMap nsMap) >+ { >+ _nsMap = nsMap; >+ _topicSpaces = new ArrayList(); >+ } >+ >+ /** >+ * >+ * @param topicExpression >+ * Topic expression for which new topicSpace to be created. >+ */ >+ public void addTopicExpression(String topicExpression) >+ { >+ TopicSpace topicSpace = getTopicSpace(topicExpression); >+ createTopic(topicSpace, topicExpression); >+ } >+ >+ /** >+ * >+ * @return Topicspaces corresponding to topic expression property. >+ */ >+ public List getTopicSpaces() >+ { >+ return _topicSpaces; >+ } >+ >+ private TopicSpace getTopicSpace(String topicExpression) >+ { >+ String prefix = topicExpression.substring(0, topicExpression >+ .indexOf(':')); >+ String namespace = (String) _nsMap.get(prefix); >+ if (!isTopicSpaceCreated(namespace)) >+ { >+ TopicSpace topicSpace = CapabilitiesFactory.eINSTANCE >+ .createTopicSpace(); >+ topicSpace.setName(prefix); >+ topicSpace.setNamespace(namespace); >+ _topicSpaces.add(topicSpace); >+ return topicSpace; >+ } >+ >+ for (int i = 0; i < _topicSpaces.size(); i++) >+ { >+ TopicSpace topicSpace = (TopicSpace) _topicSpaces.get(i); >+ if (topicSpace.getNamespace().equals(namespace)) >+ return topicSpace; >+ } >+ >+ return null; >+ } >+ >+ private boolean isTopicSpaceCreated(String namespace) >+ { >+ for (int i = 0; i < _topicSpaces.size(); i++) >+ { >+ TopicSpace topicSpace = (TopicSpace) _topicSpaces.get(i); >+ if (topicSpace.getNamespace().equals(namespace)) >+ return true; >+ } >+ return false; >+ } >+ >+ private void createTopic(TopicSpace topicSpace, String topicExpression) >+ { >+ String path = topicExpression >+ .substring(topicExpression.indexOf(':') + 1); >+ StringTokenizer tokenizer = new StringTokenizer(path, "/"); >+ >+ String rootTopicName = tokenizer.nextToken(); >+ Topic parentTopic = null; >+ if (!isTopicCreated(topicSpace, rootTopicName)) >+ { >+ parentTopic = createRootTopic(topicSpace, rootTopicName); >+ } >+ else >+ { >+ parentTopic = getRootTopic(topicSpace, rootTopicName); >+ } >+ >+ while (tokenizer.hasMoreTokens()) >+ { >+ String childTopicName = tokenizer.nextToken(); >+ if (!isTopicCreated(parentTopic, childTopicName)) >+ { >+ parentTopic = createChildTopic(parentTopic, childTopicName); >+ } >+ else >+ { >+ parentTopic = getChildTopic(parentTopic, childTopicName); >+ } >+ } >+ } >+ >+ private boolean isTopicCreated(TopicSpace topicSpace, String rootTopicName) >+ { >+ for (int i = 0; i < topicSpace.getRootTopics().size(); i++) >+ { >+ Topic rootTopic = (Topic) topicSpace.getRootTopics().get(i); >+ if (rootTopic.getName().equals(rootTopicName)) >+ return true; >+ } >+ return false; >+ } >+ >+ private boolean isTopicCreated(Topic parentTopic, String childTopicName) >+ { >+ for (int i = 0; i < parentTopic.getChildren().size(); i++) >+ { >+ Topic childTopic = (Topic) parentTopic.getChildren().get(i); >+ if (childTopic.getName().equals(childTopicName)) >+ return true; >+ } >+ return false; >+ } >+ >+ private Topic createRootTopic(TopicSpace topicSpace, String rootTopicName) >+ { >+ Topic rootTopic = CapabilitiesFactory.eINSTANCE.createTopic(); >+ rootTopic.setName(rootTopicName); >+ rootTopic.setParent(null); >+ topicSpace.getRootTopics().add(rootTopic); >+ return rootTopic; >+ } >+ >+ private Topic getRootTopic(TopicSpace topicSpace, String rootTopicName) >+ { >+ for (int i = 0; i < topicSpace.getRootTopics().size(); i++) >+ { >+ Topic rootTopic = (Topic) topicSpace.getRootTopics().get(i); >+ if (rootTopic.getName().equals(rootTopicName)) >+ return rootTopic; >+ } >+ return null; >+ } >+ >+ private Topic createChildTopic(Topic topic, String childTopicName) >+ { >+ Topic childTopic = CapabilitiesFactory.eINSTANCE.createTopic(); >+ childTopic.setName(childTopicName); >+ childTopic.setParent(topic); >+ topic.getChildren().add(childTopic); >+ return childTopic; >+ } >+ >+ private Topic getChildTopic(Topic parentTopic, String childTopicName) >+ { >+ for (int i = 0; i < parentTopic.getChildren().size(); i++) >+ { >+ Topic childTopic = (Topic) parentTopic.getChildren().get(i); >+ if (childTopic.getName().equals(childTopicName)) >+ return childTopic; >+ } >+ return null; >+ } >+} >Index: src/org/eclipse/tptp/wsdm/tooling/model/capabilities/Metrics.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/model/capabilities/Metrics.java >diff -N src/org/eclipse/tptp/wsdm/tooling/model/capabilities/Metrics.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/model/capabilities/Metrics.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,141 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Balan Subramanian (bsubram@us.ibm.com) >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.tptp.wsdm.tooling.model.capabilities; >+ >+import org.eclipse.emf.ecore.EObject; >+ >+/** >+ * <!-- begin-user-doc --> >+ * A representation of the model object '<em><b>Metrics</b></em>'. >+ * <!-- end-user-doc --> >+ * >+ * <p> >+ * The following features are supported: >+ * <ul> >+ * <li>{@link org.eclipse.tptp.wsdm.tooling.model.capabilities.Metrics#getChangeType <em>Change Type</em>}</li> >+ * <li>{@link org.eclipse.tptp.wsdm.tooling.model.capabilities.Metrics#getTimeScope <em>Time Scope</em>}</li> >+ * <li>{@link org.eclipse.tptp.wsdm.tooling.model.capabilities.Metrics#getGatheringTime <em>Gathering Time</em>}</li> >+ * <li>{@link org.eclipse.tptp.wsdm.tooling.model.capabilities.Metrics#getCalculationInterval <em>Calculation Interval</em>}</li> >+ * </ul> >+ * </p> >+ * >+ * @see org.eclipse.tptp.wsdm.tooling.model.capabilities.CapabilitiesPackage#getMetrics() >+ * @model >+ * @generated >+ */ >+public interface Metrics extends EObject { >+ /** >+ * Returns the value of the '<em><b>Change Type</b></em>' attribute. >+ * <!-- begin-user-doc --> >+ * <p> >+ * If the meaning of the '<em>Change Type</em>' attribute isn't clear, >+ * there really should be more of a description here... >+ * </p> >+ * <!-- end-user-doc --> >+ * @return the value of the '<em>Change Type</em>' attribute. >+ * @see #setChangeType(String) >+ * @see org.eclipse.tptp.wsdm.tooling.model.capabilities.CapabilitiesPackage#getMetrics_ChangeType() >+ * @model >+ * @generated >+ */ >+ String getChangeType(); >+ >+ /** >+ * Sets the value of the '{@link org.eclipse.tptp.wsdm.tooling.model.capabilities.Metrics#getChangeType <em>Change Type</em>}' attribute. >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @param value the new value of the '<em>Change Type</em>' attribute. >+ * @see #getChangeType() >+ * @generated >+ */ >+ void setChangeType(String value); >+ >+ /** >+ * Returns the value of the '<em><b>Time Scope</b></em>' attribute. >+ * <!-- begin-user-doc --> >+ * <p> >+ * If the meaning of the '<em>Time Scope</em>' attribute isn't clear, >+ * there really should be more of a description here... >+ * </p> >+ * <!-- end-user-doc --> >+ * @return the value of the '<em>Time Scope</em>' attribute. >+ * @see #setTimeScope(String) >+ * @see org.eclipse.tptp.wsdm.tooling.model.capabilities.CapabilitiesPackage#getMetrics_TimeScope() >+ * @model >+ * @generated >+ */ >+ String getTimeScope(); >+ >+ /** >+ * Sets the value of the '{@link org.eclipse.tptp.wsdm.tooling.model.capabilities.Metrics#getTimeScope <em>Time Scope</em>}' attribute. >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @param value the new value of the '<em>Time Scope</em>' attribute. >+ * @see #getTimeScope() >+ * @generated >+ */ >+ void setTimeScope(String value); >+ >+ /** >+ * Returns the value of the '<em><b>Gathering Time</b></em>' attribute. >+ * <!-- begin-user-doc --> >+ * <p> >+ * If the meaning of the '<em>Gathering Time</em>' attribute isn't clear, >+ * there really should be more of a description here... >+ * </p> >+ * <!-- end-user-doc --> >+ * @return the value of the '<em>Gathering Time</em>' attribute. >+ * @see #setGatheringTime(String) >+ * @see org.eclipse.tptp.wsdm.tooling.model.capabilities.CapabilitiesPackage#getMetrics_GatheringTime() >+ * @model >+ * @generated >+ */ >+ String getGatheringTime(); >+ >+ /** >+ * Sets the value of the '{@link org.eclipse.tptp.wsdm.tooling.model.capabilities.Metrics#getGatheringTime <em>Gathering Time</em>}' attribute. >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @param value the new value of the '<em>Gathering Time</em>' attribute. >+ * @see #getGatheringTime() >+ * @generated >+ */ >+ void setGatheringTime(String value); >+ >+ /** >+ * Returns the value of the '<em><b>Calculation Interval</b></em>' attribute. >+ * <!-- begin-user-doc --> >+ * <p> >+ * If the meaning of the '<em>Calculation Interval</em>' attribute isn't clear, >+ * there really should be more of a description here... >+ * </p> >+ * <!-- end-user-doc --> >+ * @return the value of the '<em>Calculation Interval</em>' attribute. >+ * @see #setCalculationInterval(String) >+ * @see org.eclipse.tptp.wsdm.tooling.model.capabilities.CapabilitiesPackage#getMetrics_CalculationInterval() >+ * @model >+ * @generated >+ */ >+ String getCalculationInterval(); >+ >+ /** >+ * Sets the value of the '{@link org.eclipse.tptp.wsdm.tooling.model.capabilities.Metrics#getCalculationInterval <em>Calculation Interval</em>}' attribute. >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @param value the new value of the '<em>Calculation Interval</em>' attribute. >+ * @see #getCalculationInterval() >+ * @generated >+ */ >+ void setCalculationInterval(String value); >+ >+} // Metrics >Index: src/org/eclipse/tptp/wsdm/tooling/model/capabilities/impl/MetadataDescriptor.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/model/capabilities/impl/MetadataDescriptor.java >diff -N src/org/eclipse/tptp/wsdm/tooling/model/capabilities/impl/MetadataDescriptor.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/model/capabilities/impl/MetadataDescriptor.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,466 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Balan Subramanian (bsubram@us.ibm.com) >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.tptp.wsdm.tooling.model.capabilities.impl; >+ >+import java.util.Collections; >+import java.util.Iterator; >+import java.util.LinkedList; >+import java.util.List; >+ >+import org.eclipse.emf.common.util.EMap; >+import org.eclipse.emf.ecore.EStructuralFeature; >+import org.eclipse.emf.ecore.impl.EStructuralFeatureImpl; >+import org.eclipse.emf.ecore.resource.ResourceSet; >+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; >+import org.eclipse.emf.ecore.util.BasicExtendedMetaData; >+import org.eclipse.emf.ecore.util.ExtendedMetaData; >+import org.eclipse.emf.ecore.util.FeatureMap; >+import org.eclipse.emf.ecore.util.FeatureMapUtil; >+import org.eclipse.emf.ecore.xml.type.AnyType; >+import org.eclipse.emf.ecore.xml.type.XMLTypeFactory; >+import org.eclipse.tptp.wsdm.tooling.model.capabilities.CapabilitiesFactory; >+import org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability; >+import org.eclipse.tptp.wsdm.tooling.model.capabilities.Metrics; >+import org.eclipse.tptp.wsdm.tooling.model.capabilities.Property; >+import org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.DocumentRoot; >+import org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.InitialValuesType; >+import org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.MetadataDescriptorFactory; >+import org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.MetadataDescriptorType; >+import org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.ModifiabilityType; >+import org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.MutabilityType; >+import org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.PropertyType; >+import org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.impl.MetadataDescriptorFactoryImpl; >+import org.eclipse.tptp.wsdm.tooling.model.muwsPart2.ChangeTypeType; >+import org.eclipse.tptp.wsdm.tooling.model.muwsPart2.GatheringTimeType; >+import org.eclipse.tptp.wsdm.tooling.model.muwsPart2.TimeScopeType; >+ >+public class MetadataDescriptor >+{ >+ private ExtendedMetaData _extendedMetaData; >+ >+ private DocumentRoot _root; >+ >+ private EStructuralFeature esfWSDM_Capability; >+ >+ private MetadataDescriptorFactory _rmdFactory = new MetadataDescriptorFactoryImpl(); >+ >+ private String _metadataDescriptorName; >+ >+ private MetadataDescriptorType _metadataDescriptor; >+ >+ private Capability _capability; >+ >+ // TODO >+ private String WSNT_NS = "http://docs.oasis-open.org/wsn/b-2"; >+ >+ private String MUWS_P2_NS = "http://docs.oasis-open.org/wsdm/muws2-2.xsd"; >+ >+ private String METRICS_CAPABILITY = "http://docs.oasis-open.org/wsdm/muws/capabilities/Metrics"; >+ >+ public MetadataDescriptor(Capability capability, DocumentRoot root, >+ String metadataDescriptorName) >+ { >+ _capability = capability; >+ if (_capability != null) >+ _capability.setMetadata(this); >+ _root = root; >+ _metadataDescriptorName = metadataDescriptorName; >+ _metadataDescriptor = getMetadataDescriptorType(); >+ _extendedMetaData = createExtendedMetaData(); >+ this.esfWSDM_Capability = _extendedMetaData.demandFeature(MUWS_P2_NS, >+ "Capability", true); >+ } >+ >+ private ExtendedMetaData createExtendedMetaData() >+ { >+ ResourceSet resourceSet = new ResourceSetImpl(); >+ ExtendedMetaData extendedMetaData = new BasicExtendedMetaData( >+ resourceSet.getPackageRegistry()); >+ return extendedMetaData; >+ } >+ >+ public MetadataDescriptorType getMetadataDescriptorType() >+ { >+ List descriptors = _root.getDefinitions().getMetadataDescriptor(); >+ for (int i = 0; i < descriptors.size(); i++) >+ { >+ MetadataDescriptorType mdtVal = (MetadataDescriptorType) descriptors >+ .get(i); >+ if (mdtVal.getName().equals(_metadataDescriptorName)) >+ return mdtVal; >+ } >+ return null; >+ } >+ >+ private PropertyType[] getAllPropertyTypes() >+ { >+ List capabilityProps = new LinkedList(); >+ List propList = _metadataDescriptor.getProperty(); >+ for (int i = 0; i < propList.size(); i++) >+ { >+ PropertyType property = (PropertyType) propList.get(i); >+ capabilityProps.add(property); >+ } >+ return (PropertyType[]) capabilityProps.toArray(new PropertyType[0]); >+ } >+ >+ public DocumentRoot getDocumentRoot() >+ { >+ return _root; >+ } >+ >+ public String getPrefix(String namespace) >+ { >+ if (namespace == null) >+ return null; >+ EMap map = _root.getXMLNSPrefixMap(); >+ Iterator keyIt = map.keySet().iterator(); >+ while (keyIt.hasNext()) >+ { >+ String prefix = (String) keyIt.next(); >+ String ns = (String) map.get(prefix); >+ if (ns.equals(namespace)) >+ return prefix; >+ } >+ return null; >+ } >+ >+ public String getNamespace(String prefix) >+ { >+ if (prefix == null) >+ return null; >+ EMap map = _root.getXMLNSPrefixMap(); >+ Iterator keyIt = map.keySet().iterator(); >+ while (keyIt.hasNext()) >+ { >+ String pfx = (String) keyIt.next(); >+ if (pfx.equals(prefix)) >+ return (String) map.get(pfx); >+ } >+ return null; >+ } >+ >+ public String getOrCreatePrefix(String namespace) >+ { >+ String prefix = getPrefix(namespace); >+ if (prefix != null) >+ return prefix; >+ String newPrefix = generateNewPrefix(); >+ _root.getXMLNSPrefixMap().put(newPrefix, namespace); >+ return newPrefix; >+ } >+ >+ private String generateNewPrefix() >+ { >+ int count = 0; >+ while (isPrefixExists("pfx" + count)) >+ count++; >+ return "pfx" + count; >+ } >+ >+ private boolean isPrefixExists(String prefix) >+ { >+ EMap map = _root.getXMLNSPrefixMap(); >+ Iterator keyIt = map.keySet().iterator(); >+ while (keyIt.hasNext()) >+ { >+ String pfx = (String) keyIt.next(); >+ if (pfx.equals(prefix)) >+ return true; >+ } >+ return false; >+ } >+ >+ public void loadTopicSpaces() >+ { >+ PropertyType topicExpProperty = getTopicExpressionProperty(); >+ if (topicExpProperty == null) >+ { >+ _capability.getTopicSpaces().addAll(Collections.EMPTY_LIST); >+ return; >+ } >+ >+ InitialValuesType intialValues = topicExpProperty.getInitialValues(); >+ if (intialValues == null) >+ { >+ _capability.getTopicSpaces().addAll(Collections.EMPTY_LIST); >+ return; >+ } >+ >+ FeatureMap map = intialValues.getAny(); >+ Iterator it = map.valueListIterator(); >+ MetaDataDescriptor2TopicSpace metaData2TopicSpace = new MetaDataDescriptor2TopicSpace( >+ _root.getXMLNSPrefixMap()); >+ while (it.hasNext()) >+ { >+ Object object = it.next(); >+ if (object instanceof AnyType) >+ { >+ AnyType anyType = (AnyType) object; >+ FeatureMap anyMap = anyType.getAny(); >+ Iterator topicExpIt = anyMap.valueListIterator(); >+ while (topicExpIt.hasNext()) >+ { >+ String topicExpression = (String) topicExpIt.next(); >+ metaData2TopicSpace.addTopicExpression(topicExpression); >+ } >+ } >+ } >+ _capability.getTopicSpaces().addAll( >+ metaData2TopicSpace.getTopicSpaces()); >+ } >+ >+ public PropertyType getTopicExpressionProperty() >+ { >+ PropertyType topicExpressionProperty = getPropertyMetadata( >+ "TopicExpression", WSNT_NS); >+ return topicExpressionProperty; >+ } >+ >+ public PropertyType getPropertyMetadata(String name, String namespace) >+ { >+ List properties = _metadataDescriptor.getProperty(); >+ for (int i = 0; i < properties.size(); i++) >+ { >+ PropertyType property = (PropertyType) properties.get(i); >+ String propName = property.getName(); >+ String prefix = extractPrefix(propName); >+ String namespaceURI = getNamespace(prefix); >+ String localName = extractName(propName); >+ if (name.equals(localName) && namespace.equals(namespaceURI)) >+ return property; >+ } >+ return null; >+ } >+ >+ private String extractPrefix(String str) >+ { >+ if (str == null || str.trim().equals("") || str.indexOf(':') == -1) >+ return null; >+ return str.substring(0, str.indexOf(':')); >+ } >+ >+ private String extractName(String str) >+ { >+ if (str == null || str.trim().equals("") || str.indexOf(':') == -1) >+ return null; >+ return str.substring(str.indexOf(':') + 1); >+ } >+ >+ public void saveTopicSpaces(List topicSpaces) >+ { >+ PropertyType topicExpressionProperty = getTopicExpressionProperty(); >+ if (topicExpressionProperty != null) >+ { >+ InitialValuesType intialValues = _rmdFactory >+ .createInitialValuesType(); >+ // TODO Check null for InitialValuesType and if null create new >+ // InitialValuesType >+ EMap nsMap = _root.getXMLNSPrefixMap(); >+ TopicSpace2MetaDataDescriptor topicSpace2MetaData = new TopicSpace2MetaDataDescriptor( >+ nsMap, topicSpaces); >+ String[] topicExpressions = topicSpace2MetaData >+ .getTopicExpressions(); >+ FeatureMap fm = intialValues.getAny(); >+ for (int i = 0; i < topicExpressions.length; i++) >+ { >+ EStructuralFeature esf = _extendedMetaData.demandFeature( >+ WSNT_NS, "TopicExpression", true); >+ AnyType atTopicExpression = XMLTypeFactory.eINSTANCE >+ .createAnyType(); >+ FeatureMapUtil.addText(atTopicExpression.getAny(), >+ topicExpressions[i]); >+ fm.add(esf, atTopicExpression); >+ } >+ topicExpressionProperty.setInitialValues(intialValues); >+ } >+ } >+ >+ public PropertyType[] getPropertyTypes() >+ { >+ return getAllPropertyTypes(); >+ } >+ >+ public void setDocumentRoot(DocumentRoot root) >+ { >+ _root = root; >+ } >+ >+ public void setMetadataDescriptorType( >+ MetadataDescriptorType metadataDescriptor) >+ { >+ _metadataDescriptor = metadataDescriptor; >+ } >+ >+ public void setMetadataDescriptorName(String metadataDescriptorName) >+ { >+ _metadataDescriptorName = metadataDescriptorName; >+ if (_metadataDescriptor != null) >+ _metadataDescriptor.setName(metadataDescriptorName); >+ } >+ >+ public PropertyType createNewPropertyType() >+ { >+ PropertyType propertyType = _rmdFactory.createPropertyType(); >+ _metadataDescriptor.getProperty().add(propertyType); >+ return propertyType; >+ } >+ >+ public PropertyType createTopicExpressionProperty() >+ { >+ _root.getXMLNSPrefixMap().put("wsnt", WSNT_NS); >+ PropertyType topicExp = _rmdFactory.createPropertyType(); >+ topicExp.setModifiability(ModifiabilityType.READ_ONLY_LITERAL); >+ topicExp.setMutability(MutabilityType.MUTABLE_LITERAL); >+ topicExp.setName("wsnt:TopicExpression"); >+ InitialValuesType initialValues = _rmdFactory.createInitialValuesType(); >+ topicExp.setInitialValues(initialValues); >+ >+ FeatureMap fm = topicExp.getAny(); >+ AnyType atCapability = XMLTypeFactory.eINSTANCE.createAnyType(); >+ FeatureMapUtil.addText(atCapability.getAny(), WSNT_NS); >+ fm.add(esfWSDM_Capability, atCapability); >+ >+ _metadataDescriptor.getProperty().add(topicExp); >+ return topicExp; >+ } >+ >+ public Metrics getMetrics(PropertyType propertyMetadata) >+ { >+ boolean metricsCapabilityFound = false; >+ String changeType = null; >+ String timeScope = null; >+ String gatheringTime = null; >+ String calculationInterval = null; >+ FeatureMap fm = propertyMetadata.getAny(); >+ Iterator it = fm.iterator(); >+ while (it.hasNext()) >+ { >+ Object obj = it.next(); >+ if (obj instanceof EStructuralFeatureImpl.SimpleFeatureMapEntry) >+ { >+ EStructuralFeatureImpl.SimpleFeatureMapEntry entry = (EStructuralFeatureImpl.SimpleFeatureMapEntry) obj; >+ if (entry.getValue() instanceof ChangeTypeType) >+ { >+ ChangeTypeType changeTypeType = (ChangeTypeType) entry >+ .getValue(); >+ changeType = changeTypeType.getLiteral(); >+ } >+ if (entry.getValue() instanceof TimeScopeType) >+ { >+ TimeScopeType timeScopeType = (TimeScopeType) entry >+ .getValue(); >+ timeScope = timeScopeType.getLiteral(); >+ } >+ if (entry.getValue() instanceof GatheringTimeType) >+ { >+ GatheringTimeType gatheringTimeType = (GatheringTimeType) entry >+ .getValue(); >+ gatheringTime = gatheringTimeType.getLiteral(); >+ } >+ if (entry.getEStructuralFeature().getName().equals( >+ "calculationInterval")) >+ { >+ calculationInterval = entry.getValue().toString(); >+ } >+ if (entry.getEStructuralFeature().getName() >+ .equals("capability")) >+ { >+ if (entry.getValue() instanceof String >+ && entry.getValue().equals(METRICS_CAPABILITY)) >+ metricsCapabilityFound = true; >+ } >+ } >+ } >+ >+ if (metricsCapabilityFound) >+ { >+ Metrics metrics = CapabilitiesFactory.eINSTANCE.createMetrics(); >+ metrics.setChangeType(changeType); >+ metrics.setTimeScope(timeScope); >+ metrics.setGatheringTime(gatheringTime); >+ metrics.setCalculationInterval(calculationInterval); >+ return metrics; >+ } >+ >+ return null; >+ } >+ >+ public void saveMetrics() >+ { >+ List properties = _capability.getProperties(); >+ for (int i = 0; i < properties.size(); i++) >+ { >+ Property property = (Property) properties.get(i); >+ saveMetrics(property); >+ } >+ } >+ >+ private void saveMetrics(Property property) >+ { >+ Metrics metrics = property.getMetrics(); >+ PropertyType metadata = property.getMetaData(); >+ if (metadata != null) >+ metadata.getAny().clear(); >+ if (metrics == null) >+ return; >+ >+ // Create Metrics capability >+ FeatureMap featureMap = metadata.getAny(); >+ EStructuralFeature esf = _extendedMetaData.demandFeature(MUWS_P2_NS, >+ "Capability", true); >+ createExtendedMetadata(featureMap, esf, METRICS_CAPABILITY); >+ >+ // Create Change Type >+ if (metrics.getChangeType() != null) >+ { >+ esf = _extendedMetaData.demandFeature(MUWS_P2_NS, "ChangeType", >+ true); >+ createExtendedMetadata(featureMap, esf, metrics.getChangeType()); >+ } >+ >+ // Create Time Scope >+ if (metrics.getTimeScope() != null) >+ { >+ esf = _extendedMetaData >+ .demandFeature(MUWS_P2_NS, "TimeScope", true); >+ createExtendedMetadata(featureMap, esf, metrics.getTimeScope()); >+ } >+ >+ // Create Gathering Time >+ if (metrics.getGatheringTime() != null) >+ { >+ esf = _extendedMetaData.demandFeature(MUWS_P2_NS, "GatheringTime", >+ true); >+ createExtendedMetadata(featureMap, esf, metrics.getGatheringTime()); >+ } >+ >+ // Create Calculation Interval >+ if (metrics.getCalculationInterval() != null) >+ { >+ esf = _extendedMetaData.demandFeature(MUWS_P2_NS, >+ "CalculationInterval", true); >+ createExtendedMetadata(featureMap, esf, metrics >+ .getCalculationInterval()); >+ } >+ } >+ >+ private void createExtendedMetadata(FeatureMap featureMap, >+ EStructuralFeature esf, String value) >+ { >+ AnyType anyType = XMLTypeFactory.eINSTANCE.createAnyType(); >+ FeatureMapUtil.addText(anyType.getMixed(), value); >+ featureMap.add(esf, anyType); >+ } >+ >+} >#P org.eclipse.tptp.wsdm.tooling.validation >Index: src/org/eclipse/tptp/wsdm/tooling/util/internal/WsdlUtils.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.validation/src/org/eclipse/tptp/wsdm/tooling/util/internal/WsdlUtils.java,v >retrieving revision 1.9 >diff -u -r1.9 WsdlUtils.java >--- src/org/eclipse/tptp/wsdm/tooling/util/internal/WsdlUtils.java 9 Jan 2007 19:52:24 -0000 1.9 >+++ src/org/eclipse/tptp/wsdm/tooling/util/internal/WsdlUtils.java 20 Jan 2007 13:34:36 -0000 >@@ -25,7 +25,6 @@ > > import javax.xml.namespace.QName; > >-import org.apache.muse.util.xml.XmlUtils; > import org.eclipse.core.resources.IFile; > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IProgressMonitor; >@@ -72,993 +71,999 @@ > public class WsdlUtils > { > >- public static final String RESOURCE_PROPERTIES_ELEMENT_KEY = "ResourceProperties"; >+ public static final String RESOURCE_PROPERTIES_ELEMENT_KEY = "ResourceProperties"; > >- public static final String METADATA_DESCRIPTOR_LOCATION_KEY = "metadataDescriptorLocation"; >+ public static final String METADATA_DESCRIPTOR_LOCATION_KEY = "metadataDescriptorLocation"; > >- public static final String METADATA_DESCRIPTOR_KEY = "metadataDescriptor"; >+ public static final String METADATA_DESCRIPTOR_KEY = "metadataDescriptor"; > >- /** >- * 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 Definition getWSDLDefinition(IFile wsdlFile) throws Exception >- { >- URI wsdlURI = URI.createPlatformResourceURI(wsdlFile.getFullPath() >- .toString()); >- return getWSDLDefinition(wsdlURI); >- } >- >- /** >- * Returns the EMF based Definition object of the given URI of any WSDL >- * file. >- * >- * @param wsdlURI >- * URI of any WSDL file available in eclipse workbench >- * >- * @return EMF based Definition object >- * @throws Exception >- */ >- public static Definition getWSDLDefinition(URI wsdlURI) throws Exception >- { >- ResourceSet resourceSet = new ResourceSetImpl(); >- resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap() >- .put("*.wsdl", new CustomWSDLResourceFactoryImpl()); >- WSDLResourceImpl wsdlMainResource = (WSDLResourceImpl) resourceSet >- .createResource(URI.createURI("*.wsdl")); >- wsdlMainResource.setURI(wsdlURI); >- java.util.Map map = new Hashtable(); >- map.put(WSDLResourceImpl.CONTINUE_ON_LOAD_ERROR, Boolean.valueOf(true)); >- try >- { >- wsdlMainResource.load(map); >- } catch (Exception ex) >- { >- WsdmToolingLog.logError(Messages.IMPROPER_WSDL_FILE_ERROR_, ex); >- throw ex; >- } >- >- Definition definition = null; >- for (Iterator resources = resourceSet.getResources().iterator(); resources >- .hasNext();) >- { >- Object resource = resources.next(); >- if (resource instanceof WSDLResourceImpl) >- { >- WSDLResourceImpl wsdlResource = (WSDLResourceImpl) resource; >- definition = wsdlResource.getDefinition(); >- if (definition.getTargetNamespace() == null) // Not a proper >- // WSDL file >- throw new Exception(Messages.IMPROPER_WSDL_FILE_ERROR_); >+ /** >+ * 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 Definition getWSDLDefinition(IFile wsdlFile) throws Exception >+ { >+ URI wsdlURI = URI.createPlatformResourceURI(wsdlFile.getFullPath() >+ .toString()); >+ return getWSDLDefinition(wsdlURI); >+ } >+ >+ /** >+ * Returns the EMF based Definition object of the given URI of any WSDL >+ * file. >+ * >+ * @param wsdlURI >+ * URI of any WSDL file available in eclipse workbench >+ * >+ * @return EMF based Definition object >+ * @throws Exception >+ */ >+ public static Definition getWSDLDefinition(URI wsdlURI) throws Exception >+ { >+ ResourceSet resourceSet = new ResourceSetImpl(); >+ resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap() >+ .put("*.wsdl", new CustomWSDLResourceFactoryImpl()); >+ WSDLResourceImpl wsdlMainResource = (WSDLResourceImpl) resourceSet >+ .createResource(URI.createURI("*.wsdl")); >+ wsdlMainResource.setURI(wsdlURI); >+ java.util.Map map = new Hashtable(); >+ map.put(WSDLResourceImpl.CONTINUE_ON_LOAD_ERROR, Boolean.valueOf(true)); >+ try >+ { >+ wsdlMainResource.load(map); >+ } catch (Exception ex) >+ { >+ WsdmToolingLog.logError(Messages.IMPROPER_WSDL_FILE_ERROR_, ex); >+ throw ex; >+ } >+ >+ Definition definition = null; >+ for (Iterator resources = resourceSet.getResources().iterator(); resources >+ .hasNext();) >+ { >+ Object resource = resources.next(); >+ if (resource instanceof WSDLResourceImpl) >+ { >+ WSDLResourceImpl wsdlResource = (WSDLResourceImpl) resource; >+ definition = wsdlResource.getDefinition(); >+ if (definition.getTargetNamespace() == null) // Not a proper >+ // WSDL file >+ throw new Exception(Messages.IMPROPER_WSDL_FILE_ERROR_); >+ return definition; >+ } >+ } >+ >+ return null; >+ } >+ >+ /** >+ * Returns the WSDL Operation defined inside given port type index. If WSDL >+ * file does not contain port type then it will return null. If the given >+ * port type index is less than 0 then it will return null. If the given >+ * port type index is greater than the available port types then it will >+ * return null. >+ * >+ * @param definition >+ * WSDL Definition object. >+ * >+ * @param portTypeIndex >+ * Port type index. >+ * >+ * @return Operations available in given port type index. >+ */ >+ public static Operation[] getWSDLOperation(Definition definition, >+ int portTypeIndex) >+ { >+ PortType portType = getPortType(definition, portTypeIndex); >+ if (portType == null) >+ return null; >+ return (Operation[]) portType.getOperations().toArray(); >+ } >+ >+ /** >+ * Returns the WSDL Operation defined inside first port type. >+ * >+ * @param definition >+ * WSDL Definition object. >+ * >+ * @return Operations available inside first port type. >+ */ >+ public static Operation[] getWSDLOperation(Definition definition) >+ { >+ return getWSDLOperation(definition, 0); >+ } >+ >+ /** >+ * Returns the Port Type defined inside given WSDL Definition object. If >+ * WSDL file does not contain port type then it will return null. If the >+ * given port type index is less than 0 then it will return null. If the >+ * given port type index is greater than the available port types then it >+ * will return null. >+ * >+ * @param definition >+ * WSDL Definition object. >+ * >+ * @param portTypeIndex >+ * Port type index. >+ * >+ * @return Port Type defined inside given WSDL Definition object. >+ */ >+ public static PortType getPortType(Definition definition, int portTypeIndex) >+ { >+ if (portTypeIndex < 0) >+ { >+ WsdmToolingLog >+ .logWarning(Messages.PORT_TYPE_INDEX_LESS_THAN_0_ERROR_); >+ return null; >+ } >+ List portTypeList = definition.getEPortTypes(); >+ if (portTypeList == null || portTypeList.size() == 0) >+ { >+ // Don't log message in Error log it will go to problems view while >+ // validating mcap files >+ // WsdmToolingLog.logWarning(Messages.PORT_TYPE_NOT_FOUND_ERROR_); >+ return null; >+ } >+ if (portTypeIndex > portTypeList.size()) >+ { >+ WsdmToolingLog.logWarning(NLS.bind( >+ Messages.PORT_TYPE_INDEX_CANT_MORE_ERROR_, Integer >+ .toString(portTypeList.size()))); >+ return null; >+ } >+ PortType portType = (PortType) portTypeList.get(portTypeIndex); >+ return portType; >+ } >+ >+ /** >+ * Returns the first Port Type defined inside given WSDL Definition object. >+ * >+ * @param definition >+ * WSDL Definition object. >+ * >+ * @return First Port Type defined inside given WSDL Definition object. >+ */ >+ public static PortType getPortType(Definition definition) >+ { >+ return getPortType(definition, 0); >+ } >+ >+ /** >+ * Returns the name of given WSDL Operation object. >+ * >+ * @param operation >+ * WSDL Operation object. >+ * >+ * @return Name of WSDL Operation object. >+ */ >+ public static String getOperationName(Operation operation) >+ { >+ return operation.getName(); >+ } >+ >+ /** >+ * Create new WSDL Definition object. >+ * >+ * @param targetNamespace >+ * TargetNamespace to be used for new WSDL Definition. >+ * >+ * @param prefix >+ * TargetNamespace prefix to be used. >+ * >+ * @param name >+ * Name for WSDL Definition. It will appear as "name" attribute >+ * inside "deinition" element. >+ * >+ * @param location >+ * WSDL File location. >+ * >+ * @return new WSDL Definition object. >+ */ >+ public static Definition createNewWSDLDefinition(String targetNamespace, >+ String prefix, String name, String location) >+ { >+ Definition definition = WSDLFactory.eINSTANCE.createDefinition(); >+ definition.setTargetNamespace(targetNamespace); >+ definition.addNamespace("xsd", XsdUtils.XMLSCHEMA_2001_URI); >+ definition.addNamespace("soap", WsdlConstants.SOAP_NAMESPACE_URI); >+ definition.addNamespace("wsdl", WsdlConstants.WSDL_NAMESPACE_URI); >+ definition.setLocation(location); >+ definition.setEncoding("UTF-8"); >+ definition.setQName(new QName(targetNamespace, name)); >+ if (prefix != null) >+ definition.addNamespace(prefix, targetNamespace); >+ else >+ definition.addNamespace("tns", targetNamespace); >+ definition.updateElement(true); > return definition; >- } > } > >- return null; >- } >+ /** >+ * Saves an WSDL Definition object into ResourceSet and returns the >+ * ByteArrayOutputStream of the saved object. >+ * >+ * @param definition >+ * WSDL Definition object to be saved. >+ * >+ * @param fileURI >+ * URI String of the file to which WSDL Definition object will be >+ * saved. >+ * >+ * @param resourceSet >+ * ResourceSet used for saving it, if null ResourceSet specified >+ * then the method will create new ResourceSet. >+ * >+ * @return ByteArrayOutputStream representation of the saved object. >+ * @throws IOException >+ */ >+ public static ByteArrayOutputStream saveWSDLDefinition( >+ Definition definition, String fileURI, ResourceSet resourceSet) >+ throws IOException >+ { >+ if (resourceSet == null) >+ { >+ resourceSet = new ResourceSetImpl(); >+ } >+ resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap() >+ .put(Resource.Factory.Registry.DEFAULT_EXTENSION, >+ new CustomWSDLResourceFactoryImpl()); >+ URI wsdlFileURI = URI.createPlatformResourceURI(fileURI); >+ Resource resource = resourceSet.createResource(wsdlFileURI); >+ resource.getContents().add(definition); >+ Map options = new HashMap(); >+ ByteArrayOutputStream baOutputStream = new ByteArrayOutputStream(); >+ try >+ { >+ resource.save(baOutputStream, options); >+ } catch (IOException e) >+ { >+ WsdmToolingLog >+ .logError(Messages.FAILED_TO_SAVE_MCAP_FILE_ERROR_, e); >+ throw e; >+ } >+ return baOutputStream; >+ } > >- /** >- * Returns the WSDL Operation defined inside given port type index. If >- * WSDL file does not contain port type then it will return null. If the >- * given port type index is less than 0 then it will return null. If the >- * given port type index is greater than the available port types then >- * it will return null. >- * >- * @param definition >- * WSDL Definition object. >- * >- * @param portTypeIndex >- * Port type index. >- * >- * @return Operations available in given port type index. >- */ >- public static Operation[] getWSDLOperation(Definition definition, >- int portTypeIndex) >- { >- PortType portType = getPortType(definition, portTypeIndex); >- if (portType == null) >- return null; >- return (Operation[]) portType.getOperations().toArray(); >- } >- >- /** >- * Returns the WSDL Operation defined inside first port type. >- * >- * @param definition >- * WSDL Definition object. >- * >- * @return Operations available inside first port type. >- */ >- public static Operation[] getWSDLOperation(Definition definition) >- { >- return getWSDLOperation(definition, 0); >- } >- >- /** >- * Returns the Port Type defined inside given WSDL Definition object. If >- * WSDL file does not contain port type then it will return null. If the >- * given port type index is less than 0 then it will return null. If the >- * given port type index is greater than the available port types then >- * it will return null. >- * >- * @param definition >- * WSDL Definition object. >- * >- * @param portTypeIndex >- * Port type index. >- * >- * @return Port Type defined inside given WSDL Definition object. >- */ >- public static PortType getPortType(Definition definition, int portTypeIndex) >- { >- if (portTypeIndex < 0) >- { >- WsdmToolingLog >- .logWarning(Messages.PORT_TYPE_INDEX_LESS_THAN_0_ERROR_); >- return null; >- } >- List portTypeList = definition.getEPortTypes(); >- if (portTypeList == null || portTypeList.size() == 0) >- { >- // Don't log message in Error log it will go to problems view while validating mcap files >- //WsdmToolingLog.logWarning(Messages.PORT_TYPE_NOT_FOUND_ERROR_); >- return null; >- } >- if (portTypeIndex > portTypeList.size()) >- { >- WsdmToolingLog.logWarning(NLS.bind( >- Messages.PORT_TYPE_INDEX_CANT_MORE_ERROR_, Integer >- .toString(portTypeList.size()))); >- return null; >- } >- PortType portType = (PortType) portTypeList.get(portTypeIndex); >- return portType; >- } >- >- /** >- * Returns the first Port Type defined inside given WSDL Definition >- * object. >- * >- * @param definition >- * WSDL Definition object. >- * >- * @return First Port Type defined inside given WSDL Definition object. >- */ >- public static PortType getPortType(Definition definition) >- { >- return getPortType(definition, 0); >- } >- >- /** >- * Returns the name of given WSDL Operation object. >- * >- * @param operation >- * WSDL Operation object. >- * >- * @return Name of WSDL Operation object. >- */ >- public static String getOperationName(Operation operation) >- { >- return operation.getName(); >- } >- >- /** >- * Create new WSDL Definition object. >- * >- * @param targetNamespace >- * TargetNamespace to be used for new WSDL Definition. >- * >- * @param prefix >- * TargetNamespace prefix to be used. >- * >- * @param name >- * Name for WSDL Definition. It will appear as "name" >- * attribute inside "deinition" element. >- * >- * @param location >- * WSDL File location. >- * >- * @return new WSDL Definition object. >- */ >- public static Definition createNewWSDLDefinition(String targetNamespace, >- String prefix, String name, String location) >- { >- Definition definition = WSDLFactory.eINSTANCE.createDefinition(); >- definition.setTargetNamespace(targetNamespace); >- definition.addNamespace("xsd", XsdUtils.XMLSCHEMA_2001_URI); >- definition.addNamespace("soap", WsdlConstants.SOAP_NAMESPACE_URI); >- definition.addNamespace("wsdl", WsdlConstants.WSDL_NAMESPACE_URI); >- definition.setLocation(location); >- definition.setEncoding("UTF-8"); >- definition.setQName(new QName(targetNamespace, name)); >- if (prefix != null) >- definition.addNamespace(prefix, targetNamespace); >- else >- definition.addNamespace("tns", targetNamespace); >- definition.updateElement(true); >- return definition; >- } >- >- /** >- * Saves an WSDL Definition object into ResourceSet and returns the >- * ByteArrayOutputStream of the saved object. >- * >- * @param definition >- * WSDL Definition object to be saved. >- * >- * @param fileURI >- * URI String of the file to which WSDL Definition object >- * will be saved. >- * >- * @param resourceSet >- * ResourceSet used for saving it, if null ResourceSet >- * specified then the method will create new ResourceSet. >- * >- * @return ByteArrayOutputStream representation of the saved object. >- * @throws IOException >- */ >- public static ByteArrayOutputStream saveWSDLDefinition( >- Definition definition, String fileURI, ResourceSet resourceSet) throws IOException >- { >- if (resourceSet == null) >- { >- resourceSet = new ResourceSetImpl(); >- } >- resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap() >- .put(Resource.Factory.Registry.DEFAULT_EXTENSION, >- new CustomWSDLResourceFactoryImpl()); >- URI wsdlFileURI = URI.createPlatformResourceURI(fileURI); >- Resource resource = resourceSet.createResource(wsdlFileURI); >- resource.getContents().add(definition); >- Map options = new HashMap(); >- ByteArrayOutputStream baOutputStream = new ByteArrayOutputStream(); >- try >- { >- resource.save(baOutputStream, options); >- } catch (IOException e) >- { >- WsdmToolingLog >- .logError(Messages.FAILED_TO_SAVE_MCAP_FILE_ERROR_, e); >- throw e; >- } >- return baOutputStream; >- } >- >- /** >- * Saves an WSDL Definition into IFile in formatted representation. >- * >- * @param definition >- * WSDL Definition object to be saved. >- * >- * @param wsdlFile >- * Eclipse file to which WSDL Definition object will be >- * saved. >- * >- * @param monitor >- * Progress monitor. >- * @throws IOException >- * @throws CoreException >- */ >- public static void serializeAndFormatWSDL(Definition definition, >- IFile wsdlFile, IProgressMonitor monitor) throws IOException, CoreException >- { >- String fileURI = wsdlFile.getFullPath().toString(); >- ByteArrayOutputStream baos = saveWSDLDefinition(definition, fileURI, >- null); >- String serializedString = CapUtils.getSerializedDocument(baos >- .toString()); >- ByteArrayInputStream baInputStream = new ByteArrayInputStream( >- serializedString.getBytes()); >- try >- { >- if (wsdlFile.exists()) >- wsdlFile.setContents(baInputStream, IFile.FORCE, monitor); >- else >- wsdlFile.create(baInputStream, IFile.FORCE, monitor); >- } catch (CoreException e) >- { >- WsdmToolingLog >- .logError(Messages.FAILED_TO_SAVE_MCAP_FILE_ERROR_, e); >- throw e; >- } >- } >- >- /** >- * It will return the XSD Schema defined inside WSDL Types. If no WSDL >- * Types are defined then this method will create new WSDL Types and >- * will create new XSDSchema and return it. If WSDL Types are defined >- * but no XSDSchema is defined then it will create new XSDSchema and >- * return it. >- * >- * @param definition >- * WSDL Definition object. >- * >- * @param tns >- * XSDSchema targetnamespace to be searched. >- * >- * @return XSDSchema object. >- */ >- public static XSDSchema createOrFindSchema(Definition definition, String tns) >- { >- XSDSchema[] schemas = getXSDSchemas(definition); >- if (schemas == null) >- { >- // No WSDL Types found >- Types types = WSDLFactory.eINSTANCE.createTypes(); >- definition.setETypes(types); >- types.setEnclosingDefinition(definition); >- } >- else >- { >- // Some schemas exists >- for (int i = 0; i < schemas.length; i++) >- { >- if (schemas[i].getTargetNamespace().equals(tns)) >- return schemas[i]; >- } >- } >- XSDSchema schema = XsdUtils.createNewXSDSchema(tns); >- XSDSchemaExtensibilityElement schemaElement = WSDLFactory.eINSTANCE >- .createXSDSchemaExtensibilityElement(); >- schemaElement.setEnclosingDefinition(definition); >- schemaElement.setSchema(schema); >- definition.getTypes().addExtensibilityElement(schemaElement); >- return schema; >- } >- >- /** >- * Returns the XSDSchema of WSDL Definition based on the namespace >- * passed. >- */ >- public static XSDSchema getSchema(Definition definition, String tns) >- { >- XSDSchema[] schemas = getXSDSchemas(definition); >- if (schemas == null) >- return null; >- for (int i = 0; i < schemas.length; i++) >- { >- String schemaTns = schemas[i].getTargetNamespace(); >- if (schemaTns != null >- && schemas[i].getTargetNamespace().equals(tns)) >- return schemas[i]; >- } >- >- // Some of the schemas in WSDL could be defined as >- // <xsd:schema> >- // <xsd:import namespace="http://docs.oasis-open.org/wsrf/rp-2" >- // schemaLocation="WS-ResourceProperties-1_2.xsd" /> >- // </xsd:schema> >- // We have to handle such type of case >- >- for (int i = 0; i < schemas.length; i++) >- { >- XSDImport[] imports = XsdUtils.getAllXSDImports(schemas[i]); >- for (int j = 0; j < imports.length; j++) >- { >- if (imports[j].getNamespace().equals(tns)) >- return imports[j].getResolvedSchema(); >- } >- >- XSDInclude[] includes = XsdUtils.getAllXSDIncludes(schemas[i]); >- for (int k = 0; k < includes.length; k++) >- { >- if (includes[k].getResolvedSchema().getTargetNamespace() >- .equals(tns)) >- return includes[k].getResolvedSchema(); >- } >- } >- // Don't log message in Error log it will go to problems view while validating mcap files >- //WsdmToolingLog.logWarning(NLS.bind(Messages.NO_SCHEMA_FOUND_FOR_NS_WARN_, tns)); >- return null; >- } >- >- /** >- * Returns the array of XSDSchema defined in WSDL Definition. >- */ >- public static XSDSchema[] getXSDSchemas(Definition def) >- { >- List schemaList = new ArrayList(); >- Types types = (Types) def.getTypes(); >- if (types == null) >- { >- WsdmToolingLog.logWarning(Messages.NO_TYPES_FOUND_ERROR_); >- return null; >- } >- List extList = types.getExtensibilityElements(); >- XSDSchemaExtensibilityElement schemaElement = null; >- Iterator it = extList.iterator(); >- while (it.hasNext()) >- { >- Object object = it.next(); >- if (object instanceof XSDSchemaExtensibilityElement) >- { >- schemaElement = (XSDSchemaExtensibilityElement) object; >- XSDSchema schema = schemaElement.getSchema(); >- schemaList.add(schema); >- } >- } >- return (XSDSchema[]) schemaList.toArray(new XSDSchema[0]); >- } >- >- /** >- * Returns XSDElementDeclaration for return type of operation. >- */ >- public static XSDElementDeclaration getReturnTypeElement(Operation operation) >- { >- if (operation.getEOutput() == null) >- return null; >- if (operation.getEOutput().getEMessage() == null) >- return null; >- List parts = operation.getEOutput().getEMessage().getEParts(); >- if (parts == null || parts.size() == 0) >- return null; >- Part part_0 = (Part) parts.get(0); >- return part_0.getElementDeclaration(); >- } >- >- /** >- * Returns Message part for return type of operation. >- */ >- public static Part getReturnTypeMessagePart(Operation operation) >- { >- if (operation.getEOutput() == null) >- return null; >- if (operation.getEOutput().getEMessage() == null) >- return null; >- List parts = operation.getEOutput().getEMessage().getEParts(); >- if (parts == null || parts.size() == 0) >- return null; >- Part part_0 = (Part) parts.get(0); >- return part_0; >- } >- >- /** >- * Returns the operation parameters as XSDElementDeclaration. >- */ >- public static XSDElementDeclaration[] getOperationParams(Operation operation) >- { >- XSDElementDeclaration[] empty_param = new XSDElementDeclaration[0]; >- if (operation.getEInput() == null) >- return empty_param; >- if (operation.getEInput().getEMessage() == null) >- return empty_param; >- List parts = operation.getEInput().getEMessage().getEParts(); >- if (parts == null || parts.size() == 0) >- return empty_param; >- >- Part part_0 = (Part) operation.getEInput().getEMessage().getEParts() >- .get(0); >- XSDElementDeclaration element = part_0.getElementDeclaration(); >- XSDTypeDefinition typeDefinition = element.getTypeDefinition(); >- if (typeDefinition == null) >- return empty_param; >- if (typeDefinition instanceof XSDComplexTypeDefinition) >- { >- XSDComplexTypeDefinition complexTypeDefinition = (XSDComplexTypeDefinition) typeDefinition; >- XSDModelGroup modelGroup = XsdUtils >- .getXSDModelGroup(complexTypeDefinition); >- return XsdUtils.getElementDeclarations(modelGroup); >- } >- return new XSDElementDeclaration[] { element }; >- } >- >- /** >- * Returns the namespace of given prefix. >- */ >- public static String getNamespace(Definition definition, String prefix) >- { >- NamedNodeMap map = definition.getElement().getAttributes(); >- for (int i = 0; i < map.getLength(); i++) >- { >- if (map.item(i) instanceof Attr) >- { >- Attr attribute = (Attr) map.item(i); >- if (attribute.getNodeName().startsWith("xmlns:")) >- { >- String pfx = attribute.getNodeName().substring( >- "xmlns:".length()); >- if (pfx.equals(prefix)) >- return attribute.getNodeValue(); >- } >- } >- } >- WsdmToolingLog.logWarning(NLS.bind( >- Messages.NO_NS_FOUND_FOR_PREFIX_WARN_, prefix)); >- return null; >- } >- >- /** >- * Returns the prefix for given namespace in WSDL Definition. >- */ >- public static String getPrefix(Definition definition, String namespace) >- { >- NamedNodeMap map = definition.getElement().getAttributes(); >- for (int i = 0; i < map.getLength(); i++) >- { >- if (map.item(i) instanceof Attr) >- { >- Attr attribute = (Attr) map.item(i); >- if (attribute.getNodeValue().equals(namespace)) >- { >- if (attribute.getNodeName().startsWith("xmlns:")) >- { >- String prefix = attribute.getNodeName().substring( >- "xmlns:".length()); >- return prefix; >- } >+ /** >+ * Saves an WSDL Definition into IFile in formatted representation. >+ * >+ * @param definition >+ * WSDL Definition object to be saved. >+ * >+ * @param wsdlFile >+ * Eclipse file to which WSDL Definition object will be saved. >+ * >+ * @param monitor >+ * Progress monitor. >+ * @throws IOException >+ * @throws CoreException >+ */ >+ public static void serializeAndFormatWSDL(Definition definition, >+ IFile wsdlFile, IProgressMonitor monitor) throws IOException, >+ CoreException >+ { >+ String fileURI = wsdlFile.getFullPath().toString(); >+ ByteArrayOutputStream baos = saveWSDLDefinition(definition, fileURI, >+ null); >+ String serializedString = CapUtils.getSerializedDocument(baos >+ .toString()); >+ ByteArrayInputStream baInputStream = new ByteArrayInputStream( >+ serializedString.getBytes()); >+ try >+ { >+ if (wsdlFile.exists()) >+ wsdlFile.setContents(baInputStream, IFile.FORCE, monitor); >+ else >+ wsdlFile.create(baInputStream, IFile.FORCE, monitor); >+ } catch (CoreException e) >+ { >+ WsdmToolingLog >+ .logError(Messages.FAILED_TO_SAVE_MCAP_FILE_ERROR_, e); >+ throw e; > } >- } > } >- WsdmToolingLog.logWarning(NLS.bind( >- Messages.NO_PREFIX_FOUND_FOR_NS_WARN_, namespace)); >- return null; >- } >- >- /** >- * Returns true if perticular namespace defined inside WSDL definition. >- */ >- public static boolean isNamespaceDefined(Definition definition, >- String namespace) >- { >- if (getPrefix(definition, namespace) == null) >- return false; >- return true; >- } >- >- /** >- * Returns the WSDL targetnamespace prefix. >- */ >- public static String getTargetNamespacePrefix(Definition def) >- { >- return getPrefix(def, def.getTargetNamespace()); >- } >- >- /** >- * Returns ResourcePropertyElement from WSDL Definition. >- */ >- public static XSDElementDeclaration getResourcePropertyElement( >- Definition definition, String resourceProperties) >- { >- String rpNsPrefix = null; >- String elementName = resourceProperties; >- if (resourceProperties.indexOf(":") != -1) >- { >- rpNsPrefix = resourceProperties.substring(0, resourceProperties >- .indexOf(":")); >- elementName = resourceProperties.substring(resourceProperties >- .indexOf(":") + 1); >- } >- XSDSchema xsdSchema = null; >- if (rpNsPrefix == null) >- { >- xsdSchema = getSchema(definition, definition.getTargetNamespace()); >- } >- else >- { >- String ns = getNamespace(definition, rpNsPrefix); >- xsdSchema = getSchema(definition, ns); >- } >- >- XSDElementDeclaration resourcePropertyElement = XsdUtils >- .getXSDElementDeclarationOfName(xsdSchema, elementName); >- if (resourcePropertyElement == null) >- WsdmToolingLog.logMessage(Messages.NO_RP_ELEMENT_ERROR_); >- return resourcePropertyElement; >- } >- >- /** >- * Returns the MetadataMap from WSDL port type.<br> >- * This map contain values for resource properties, metadatadescriptor >- * and metadatadescriptorlocation. >- * @throws CoreException >- * @throws IOException >- * @throws SAXException >- */ >- public static Map getMetadataFromPortType(IFile wsdlFile) throws CoreException, IOException, SAXException >- { >- Map map = new HashMap(); >- InputStream is = null; >- Document document = null; >- try >- { >- is = wsdlFile.getContents(); >- document = XmlUtils.createDocument(is); >- } catch (CoreException e) >- { >- WsdmToolingLog.logError(Messages.CANT_PARSE_XML_ERROR_, e); >- throw e; >- } catch (IOException e) >- { >- WsdmToolingLog.logError(Messages.CANT_PARSE_XML_ERROR_, e); >- throw e; >- } catch (SAXException e) >- { >- WsdmToolingLog.logError(Messages.CANT_PARSE_XML_ERROR_, e); >- throw e; >- } >- >- NodeList nlpt = document.getElementsByTagNameNS( >- WsdlConstants.WSDL_NAMESPACE_URI, "portType"); >- Element pte = (Element) nlpt.item(0); >- if (pte == null) >- WsdmToolingLog.logWarning(Messages.PORT_TYPE_NOT_FOUND_ERROR_); >- >- String metadataDescriptor = pte.getAttributeNS(WsdmConstants.WSRMD_NS, >- METADATA_DESCRIPTOR_KEY); >- if (metadataDescriptor == null || metadataDescriptor.equals("")) >- WsdmToolingLog.logMessage(Messages.NO_METADESCRIPTOR_WARN_); >- else >- map.put(METADATA_DESCRIPTOR_KEY, metadataDescriptor); >- >- String metadataDescriptorLocation = pte.getAttributeNS( >- WsdmConstants.WSRMD_NS, METADATA_DESCRIPTOR_LOCATION_KEY); >- if (metadataDescriptorLocation == null >- || metadataDescriptorLocation.equals("")) >- WsdmToolingLog >- .logMessage(Messages.NO_METADESCRIPTOR_LOCATION_WARN_); >- else >- map.put(METADATA_DESCRIPTOR_LOCATION_KEY, >- metadataDescriptorLocation); >- >- String resourceProperties = pte.getAttributeNS(WsdmConstants.WSRP_NS, >- RESOURCE_PROPERTIES_ELEMENT_KEY); >- if (resourceProperties == null || resourceProperties.equals("")) >- WsdmToolingLog.logMessage(Messages.NO_RP_ATTRIBUTE_WARN_); >- else >- map.put(RESOURCE_PROPERTIES_ELEMENT_KEY, resourceProperties); >- >- return map; >- } >- >- /** >- * Returns the MetadataMap from WSDL port type.<br> >- * This map contain values for resource properties, metadatadescriptor >- * and metadatadescriptorlocation. >- */ >- public static Map getMetadataFromPortType(Definition wsdlDefinition) >- { >- Map map = new HashMap(); >- Element wsdlElement = wsdlDefinition.getElement(); >- >- NodeList nlpt = wsdlElement.getElementsByTagNameNS( >- WsdlConstants.WSDL_NAMESPACE_URI, "portType"); >- Element pte = (Element) nlpt.item(0); >- if (pte == null) >- { >- // Don't log message in Error log it will go to problems view while validating mcap files >- //WsdmToolingLog.logWarning(Messages.PORT_TYPE_NOT_FOUND_ERROR_); >- return null; >- } >- >- String metadataDescriptor = pte.getAttributeNS(WsdmConstants.WSRMD_NS, >- METADATA_DESCRIPTOR_KEY); >- if (metadataDescriptor == null || metadataDescriptor.equals("")) >- { >- metadataDescriptor = null; >- // Don't log message in Error log it will go to problems view while validating mcap files >- //WsdmToolingLog.logWarning(Messages.NO_METADESCRIPTOR_WARN_); >- } >- >- String metadataDescriptorLocation = pte.getAttributeNS( >- WsdmConstants.WSRMD_NS, METADATA_DESCRIPTOR_LOCATION_KEY); >- if (metadataDescriptorLocation == null >- || metadataDescriptorLocation.equals("")) >- { >- metadataDescriptorLocation = null; >- // Don't log message in Error log it will go to problems view while validating mcap files >- //WsdmToolingLog.logWarning(Messages.NO_METADESCRIPTOR_LOCATION_WARN_); >- } >- >- String resourceProperties = pte.getAttributeNS(WsdmConstants.WSRP_NS, >- RESOURCE_PROPERTIES_ELEMENT_KEY); >- if (resourceProperties == null || resourceProperties.equals("")) >- { >- resourceProperties = null; >- // Don't log message in Error log it will go to problems view while validating mcap files >- //WsdmToolingLog.logWarning(Messages.NO_RP_ATTRIBUTE_WARN_); >- } >- >- map.put(METADATA_DESCRIPTOR_KEY, metadataDescriptor); >- map.put(METADATA_DESCRIPTOR_LOCATION_KEY, metadataDescriptorLocation); >- map.put(RESOURCE_PROPERTIES_ELEMENT_KEY, resourceProperties); >- >- return map; >- } >- >- /** >- * Returns the WSDLFileLocation from WSDL Definition. >- */ >- public static String getWSDLFileLocation(Definition definition) >- { >- if (definition.getLocation() != null >- && !definition.getLocation().equals("")) >- return definition.getLocation(); >- Resource resource = definition.eResource(); >- if (resource == null) >- { >- WsdmToolingLog.logWarning(Messages.IMPROPER_WSDL_FILE_ERROR_); >- return null; >- } >- URI uri = resource.getURI(); >- if (uri == null) >- { >- WsdmToolingLog.logWarning(Messages.IMPROPER_WSDL_FILE_ERROR_); >- return null; >- } >- return uri.toString(); >- } >- >- /** >- * Creates or return existing prefix. If the passed newPrefix is null, >- * the it generates a unique prefix for the namespace. >- */ >- public static String createOrFindPrefix(Definition definition, >- String namespace, String newPrefix) >- { >- String prefix = getPrefix(definition, namespace); >- if (prefix != null) >- return prefix; >- if (newPrefix != null) >- definition.addNamespace(newPrefix, namespace); >- else >- { >- newPrefix = generateNewPrefix(definition); >- definition.addNamespace(newPrefix, namespace); >- } >- return newPrefix; >- } >- >- private static String generateNewPrefix(Definition definition) >- { >- int count = 0; >- String prefix = "pfx" + count; >- while (isPrefixDefined(definition, prefix)) >- { >- prefix = "pfx" + count++; >- } >- return prefix; >- } >- >- private static boolean isPrefixDefined(Definition definition, String prefix) >- { >- String[] namespaces = getAllDefinedNamespaces(definition); >- for (int i = 0; i < namespaces.length; i++) >+ >+ /** >+ * It will return the XSD Schema defined inside WSDL Types. If no WSDL Types >+ * are defined then this method will create new WSDL Types and will create >+ * new XSDSchema and return it. If WSDL Types are defined but no XSDSchema >+ * is defined then it will create new XSDSchema and return it. >+ * >+ * @param definition >+ * WSDL Definition object. >+ * >+ * @param tns >+ * XSDSchema targetnamespace to be searched. >+ * >+ * @return XSDSchema object. >+ */ >+ public static XSDSchema createOrFindSchema(Definition definition, String tns) > { >- String pfx = getPrefix(definition, namespaces[i]); >- if (pfx.equals(prefix)) >- return true; >+ XSDSchema[] schemas = getXSDSchemas(definition); >+ if (schemas == null) >+ { >+ // No WSDL Types found >+ Types types = WSDLFactory.eINSTANCE.createTypes(); >+ definition.setETypes(types); >+ types.setEnclosingDefinition(definition); >+ } >+ else >+ { >+ // Some schemas exists >+ for (int i = 0; i < schemas.length; i++) >+ { >+ if (schemas[i].getTargetNamespace().equals(tns)) >+ return schemas[i]; >+ } >+ } >+ XSDSchema schema = XsdUtils.createNewXSDSchema(tns); >+ XSDSchemaExtensibilityElement schemaElement = WSDLFactory.eINSTANCE >+ .createXSDSchemaExtensibilityElement(); >+ schemaElement.setEnclosingDefinition(definition); >+ schemaElement.setSchema(schema); >+ definition.getTypes().addExtensibilityElement(schemaElement); >+ return schema; >+ } >+ >+ /** >+ * Returns the XSDSchema of WSDL Definition based on the namespace passed. >+ */ >+ public static XSDSchema getSchema(Definition definition, String tns) >+ { >+ XSDSchema[] schemas = getXSDSchemas(definition); >+ if (schemas == null) >+ return null; >+ for (int i = 0; i < schemas.length; i++) >+ { >+ String schemaTns = schemas[i].getTargetNamespace(); >+ if (schemaTns != null >+ && schemas[i].getTargetNamespace().equals(tns)) >+ return schemas[i]; >+ } >+ >+ // Some of the schemas in WSDL could be defined as >+ // <xsd:schema> >+ // <xsd:import namespace="http://docs.oasis-open.org/wsrf/rp-2" >+ // schemaLocation="WS-ResourceProperties-1_2.xsd" /> >+ // </xsd:schema> >+ // We have to handle such type of case >+ >+ for (int i = 0; i < schemas.length; i++) >+ { >+ XSDImport[] imports = XsdUtils.getAllXSDImports(schemas[i]); >+ for (int j = 0; j < imports.length; j++) >+ { >+ if (imports[j].getNamespace().equals(tns)) >+ return imports[j].getResolvedSchema(); >+ } >+ >+ XSDInclude[] includes = XsdUtils.getAllXSDIncludes(schemas[i]); >+ for (int k = 0; k < includes.length; k++) >+ { >+ if (includes[k].getResolvedSchema().getTargetNamespace() >+ .equals(tns)) >+ return includes[k].getResolvedSchema(); >+ } >+ } >+ // Don't log message in Error log it will go to problems view while >+ // validating mcap files >+ // WsdmToolingLog.logWarning(NLS.bind(Messages.NO_SCHEMA_FOUND_FOR_NS_WARN_, >+ // tns)); >+ return null; >+ } >+ >+ /** >+ * Returns the array of XSDSchema defined in WSDL Definition. >+ */ >+ public static XSDSchema[] getXSDSchemas(Definition def) >+ { >+ List schemaList = new ArrayList(); >+ Types types = (Types) def.getTypes(); >+ if (types == null) >+ { >+ WsdmToolingLog.logWarning(Messages.NO_TYPES_FOUND_ERROR_); >+ return null; >+ } >+ List extList = types.getExtensibilityElements(); >+ XSDSchemaExtensibilityElement schemaElement = null; >+ Iterator it = extList.iterator(); >+ while (it.hasNext()) >+ { >+ Object object = it.next(); >+ if (object instanceof XSDSchemaExtensibilityElement) >+ { >+ schemaElement = (XSDSchemaExtensibilityElement) object; >+ XSDSchema schema = schemaElement.getSchema(); >+ schemaList.add(schema); >+ } >+ } >+ return (XSDSchema[]) schemaList.toArray(new XSDSchema[0]); >+ } >+ >+ /** >+ * Returns XSDElementDeclaration for return type of operation. >+ */ >+ public static XSDElementDeclaration getReturnTypeElement(Operation operation) >+ { >+ if (operation.getEOutput() == null) >+ return null; >+ if (operation.getEOutput().getEMessage() == null) >+ return null; >+ List parts = operation.getEOutput().getEMessage().getEParts(); >+ if (parts == null || parts.size() == 0) >+ return null; >+ Part part_0 = (Part) parts.get(0); >+ return part_0.getElementDeclaration(); >+ } >+ >+ /** >+ * Returns Message part for return type of operation. >+ */ >+ public static Part getReturnTypeMessagePart(Operation operation) >+ { >+ if (operation.getEOutput() == null) >+ return null; >+ if (operation.getEOutput().getEMessage() == null) >+ return null; >+ List parts = operation.getEOutput().getEMessage().getEParts(); >+ if (parts == null || parts.size() == 0) >+ return null; >+ Part part_0 = (Part) parts.get(0); >+ return part_0; >+ } >+ >+ /** >+ * Returns the operation parameters as XSDElementDeclaration. >+ */ >+ public static XSDElementDeclaration[] getOperationParams(Operation operation) >+ { >+ XSDElementDeclaration[] empty_param = new XSDElementDeclaration[0]; >+ if (operation.getEInput() == null) >+ return empty_param; >+ if (operation.getEInput().getEMessage() == null) >+ return empty_param; >+ List parts = operation.getEInput().getEMessage().getEParts(); >+ if (parts == null || parts.size() == 0) >+ return empty_param; >+ >+ Part part_0 = (Part) operation.getEInput().getEMessage().getEParts() >+ .get(0); >+ XSDElementDeclaration element = part_0.getElementDeclaration(); >+ XSDTypeDefinition typeDefinition = element.getTypeDefinition(); >+ if (typeDefinition == null) >+ return empty_param; >+ if (typeDefinition instanceof XSDComplexTypeDefinition) >+ { >+ XSDComplexTypeDefinition complexTypeDefinition = (XSDComplexTypeDefinition) typeDefinition; >+ XSDModelGroup modelGroup = XsdUtils >+ .getXSDModelGroup(complexTypeDefinition); >+ return XsdUtils.getElementDeclarations(modelGroup); >+ } >+ return new XSDElementDeclaration[] { element }; >+ } >+ >+ /** >+ * Returns the namespace of given prefix. >+ */ >+ public static String getNamespace(Definition definition, String prefix) >+ { >+ NamedNodeMap map = definition.getElement().getAttributes(); >+ for (int i = 0; i < map.getLength(); i++) >+ { >+ if (map.item(i) instanceof Attr) >+ { >+ Attr attribute = (Attr) map.item(i); >+ if (attribute.getNodeName().startsWith("xmlns:")) >+ { >+ String pfx = attribute.getNodeName().substring( >+ "xmlns:".length()); >+ if (pfx.equals(prefix)) >+ return attribute.getNodeValue(); >+ } >+ } >+ } >+ WsdmToolingLog.logWarning(NLS.bind( >+ Messages.NO_NS_FOUND_FOR_PREFIX_WARN_, prefix)); >+ return null; >+ } >+ >+ /** >+ * Returns the prefix for given namespace in WSDL Definition. >+ */ >+ public static String getPrefix(Definition definition, String namespace) >+ { >+ NamedNodeMap map = definition.getElement().getAttributes(); >+ for (int i = 0; i < map.getLength(); i++) >+ { >+ if (map.item(i) instanceof Attr) >+ { >+ Attr attribute = (Attr) map.item(i); >+ if (attribute.getNodeValue().equals(namespace)) >+ { >+ if (attribute.getNodeName().startsWith("xmlns:")) >+ { >+ String prefix = attribute.getNodeName().substring( >+ "xmlns:".length()); >+ return prefix; >+ } >+ } >+ } >+ } >+ WsdmToolingLog.logWarning(NLS.bind( >+ Messages.NO_PREFIX_FOUND_FOR_NS_WARN_, namespace)); >+ return null; > } >- return false; >- } > >- /** >- * Returns all the namespaces defined in the WSDL file. >- */ >- public static String[] getAllDefinedNamespaces(Definition definition) >- { >- List namespaces = new ArrayList(); >- NamedNodeMap map = definition.getElement().getAttributes(); >- for (int i = 0; i < map.getLength(); i++) >- { >- if (map.item(i) instanceof Attr) >- { >- Attr attribute = (Attr) map.item(i); >- if (attribute.getNodeName().startsWith("xmlns:")) >- { >- String ns = attribute.getNodeValue(); >- namespaces.add(ns); >- } >- } >- } >- return (String[]) namespaces.toArray(new String[namespaces.size()]); >- } >- >- /** >- * Returns the fault name of given faultElement. >- */ >- public static String getFaultType(XSDElementDeclaration faultElement) >- { >- String default_type = faultElement.getName(); >- XSDTypeDefinition typeDef = faultElement.getTypeDefinition(); >- if (typeDef == null) >- return default_type; >- if (!(typeDef instanceof XSDComplexTypeDefinition)) >- return default_type; >- XSDComplexTypeDefinition complexTypeDef = (XSDComplexTypeDefinition) typeDef; >- XSDDerivationMethod derivationMethod = complexTypeDef >- .getDerivationMethod(); >- if (derivationMethod == null) >- return default_type; >- if (!derivationMethod.equals(XSDDerivationMethod.EXTENSION_LITERAL)) >- return default_type; >- XSDTypeDefinition baseTypeDef = complexTypeDef.getBaseTypeDefinition(); >- if (baseTypeDef == null) >- return default_type; >- if (!(baseTypeDef instanceof XSDSimpleTypeDefinition)) >- return default_type; >- XSDSimpleTypeDefinition simpleBaseTypeDef = (XSDSimpleTypeDefinition) baseTypeDef; >- return simpleBaseTypeDef.getName(); >- } >- >- /** >- * Returns the XSD fault elements of given wsdl operation. >- */ >- public static List getOperationFaultElements(Operation operation) >- { >- List retVal = new ArrayList(); >- List faults = operation.getEFaults(); >- for (int i = 0; i < faults.size(); i++) >- { >- Fault fault = (Fault) faults.get(i); >- XSDElementDeclaration faultElement = getFaultElement(fault); >- if (faultElement != null) >- retVal.add(faultElement); >- } >- return retVal; >- } >- >- /** >- * Retruns the XSD fault elements of given wsdl fault. >- */ >- public static XSDElementDeclaration getFaultElement(Fault fault) >- { >- Message msg = fault.getEMessage(); >- Part part_0 = (Part) msg.getEParts().get(0); >- XSDElementDeclaration element = part_0.getElementDeclaration(); >- return element; >- } >- >- /** >- * Returns the message which contains the given XSDElementDeclaration. >- */ >- public static Message getMessage(Definition definition, >- XSDElementDeclaration element) >- { >- List msgs = definition.getEMessages(); >- for (int i = 0; i < msgs.size(); i++) >- { >- Message msg = (Message) msgs.get(i); >- Part part = getPart(msg, element); >- if (part != null) >- return msg; >- } >- return null; >- } >- >- private static Part getPart(Message msg, XSDElementDeclaration element) >- { >- List parts = msg.getEParts(); >- for (int i = 0; i < parts.size(); i++) >- { >- Part part = (Part) parts.get(i); >- XSDElementDeclaration partElement = part.getElementDeclaration(); >- if (element.equals(partElement)) >- return part; >- } >- return null; >- } >- >- /** >- * Returns the Fault of given Message. >- */ >- public static Fault getFault(Operation operation, Message message) >- { >- List faults = operation.getEFaults(); >- for (int i = 0; i < faults.size(); i++) >- { >- Fault fault = (Fault) faults.get(i); >- Message msg = fault.getEMessage(); >- if (message.equals(msg)) >- return fault; >- } >- return null; >- } >- >- /** >- * Returns the name of WSDL Definition. >- */ >- public static String getName(Definition wsdlDef) >- { >- return wsdlDef.getQName().getLocalPart(); >- } >- >- /** >- * Create a new WSDL Import element inside given Definition. If imported >- * namespace or wsdlLocation is null then it does nothing. If imported >- * namespace is already imported in one of the WSDL Import element of >- * the WSDL then it does nothing. >- * >- * @param definition >- * Given WSDL definition inside which this new WSDL >- * Import element will be added. >- * >- * @param namespace >- * Namespace to be imported. >- * >- * @param wsdlLocation >- * WSDL location to be imported. >- */ >- public static void createWSDLImport(Definition definition, >- String namespace, String wsdlLocation) >- { >- if (namespace == null || wsdlLocation == null) >- return; >- /* >- * if (definition.getTargetNamespace().equals(namespace)) return; >- */ >- if (!isImportNSExists(definition, namespace)) >- { >- Import wsdlImport = WSDLFactory.eINSTANCE.createImport(); >- wsdlImport.setEnclosingDefinition(definition); >- wsdlImport.setEDefinition(definition); >- wsdlImport.setLocationURI(wsdlLocation); >- wsdlImport.setNamespaceURI(namespace); >- definition.addImport(wsdlImport); >- createOrFindPrefix(definition, namespace, null); >- } >- } >- >- /** >- * Check if perticular import already exists in given WSDL definition. >- */ >- public static boolean isImportNSExists(Definition definition, >- String namespace) >- { >- List imports = definition.getEImports(); >- for (int i = 0; i < imports.size(); i++) >+ /** >+ * Returns true if perticular namespace defined inside WSDL definition. >+ */ >+ public static boolean isNamespaceDefined(Definition definition, >+ String namespace) > { >- Import wsdlImport = (Import) imports.get(i); >- if (wsdlImport.getNamespaceURI().equals(namespace)) >+ if (getPrefix(definition, namespace) == null) >+ return false; > return true; > } >- return false; >- } > >- /** >- * Returns the absolute path of given WSDL defintion in the local file >- * system. >- * @throws CoreException >- */ >- public static String getLocalSystemWSDLLocation(Definition definition) throws CoreException >- { >- String uriLocation = getWSDLFileLocation(definition); >- String wsdlLocation = uriLocation; >- try >- { >- IFile wsdlFile = EclipseUtils.getIFile(uriLocation); >- wsdlLocation = wsdlFile.getLocation().toString(); >- wsdlLocation = EclipseUtils.replaceAll(wsdlLocation, '\\', '/'); >- } catch (CoreException e) >- { >- WsdmToolingLog >- .logError( >- NLS >- .bind( >- org.eclipse.tptp.wsdm.tooling.nls.messages.capability.property.internal.Messages.FAILED_TO_FIND_LOCATION_FOR_XSD_ERROR_, >- uriLocation), e); >- throw e; >+ /** >+ * Returns the WSDL targetnamespace prefix. >+ */ >+ public static String getTargetNamespacePrefix(Definition def) >+ { >+ return getPrefix(def, def.getTargetNamespace()); >+ } >+ >+ /** >+ * Returns ResourcePropertyElement from WSDL Definition. >+ */ >+ public static XSDElementDeclaration getResourcePropertyElement( >+ Definition definition, String resourceProperties) >+ { >+ String rpNsPrefix = null; >+ String elementName = resourceProperties; >+ if (resourceProperties.indexOf(":") != -1) >+ { >+ rpNsPrefix = resourceProperties.substring(0, resourceProperties >+ .indexOf(":")); >+ elementName = resourceProperties.substring(resourceProperties >+ .indexOf(":") + 1); >+ } >+ XSDSchema xsdSchema = null; >+ if (rpNsPrefix == null) >+ { >+ xsdSchema = getSchema(definition, definition.getTargetNamespace()); >+ } >+ else >+ { >+ String ns = getNamespace(definition, rpNsPrefix); >+ xsdSchema = getSchema(definition, ns); >+ } >+ >+ XSDElementDeclaration resourcePropertyElement = XsdUtils >+ .getXSDElementDeclarationOfName(xsdSchema, elementName); >+ if (resourcePropertyElement == null) >+ WsdmToolingLog.logMessage(Messages.NO_RP_ELEMENT_ERROR_); >+ return resourcePropertyElement; >+ } >+ >+ /** >+ * Returns the MetadataMap from WSDL port type.<br> >+ * This map contain values for resource properties, metadatadescriptor and >+ * metadatadescriptorlocation. >+ * >+ * @throws CoreException >+ * @throws IOException >+ * @throws SAXException >+ */ >+ public static Map getMetadataFromPortType(IFile wsdlFile) >+ throws CoreException, IOException, SAXException >+ { >+ Map map = new HashMap(); >+ InputStream is = null; >+ Document document = null; >+ try >+ { >+ is = wsdlFile.getContents(); >+ document = CapUtils.createDocument(is); >+ } catch (CoreException e) >+ { >+ WsdmToolingLog.logError(Messages.CANT_PARSE_XML_ERROR_, e); >+ throw e; >+ } catch (IOException e) >+ { >+ WsdmToolingLog.logError(Messages.CANT_PARSE_XML_ERROR_, e); >+ throw e; >+ } catch (SAXException e) >+ { >+ WsdmToolingLog.logError(Messages.CANT_PARSE_XML_ERROR_, e); >+ throw e; >+ } >+ >+ NodeList nlpt = document.getElementsByTagNameNS( >+ WsdlConstants.WSDL_NAMESPACE_URI, "portType"); >+ Element pte = (Element) nlpt.item(0); >+ if (pte == null) >+ WsdmToolingLog.logWarning(Messages.PORT_TYPE_NOT_FOUND_ERROR_); >+ >+ String metadataDescriptor = pte.getAttributeNS(WsdmConstants.WSRMD_NS, >+ METADATA_DESCRIPTOR_KEY); >+ if (metadataDescriptor == null || metadataDescriptor.equals("")) >+ WsdmToolingLog.logMessage(Messages.NO_METADESCRIPTOR_WARN_); >+ else >+ map.put(METADATA_DESCRIPTOR_KEY, metadataDescriptor); >+ >+ String metadataDescriptorLocation = pte.getAttributeNS( >+ WsdmConstants.WSRMD_NS, METADATA_DESCRIPTOR_LOCATION_KEY); >+ if (metadataDescriptorLocation == null >+ || metadataDescriptorLocation.equals("")) >+ WsdmToolingLog >+ .logMessage(Messages.NO_METADESCRIPTOR_LOCATION_WARN_); >+ else >+ map.put(METADATA_DESCRIPTOR_LOCATION_KEY, >+ metadataDescriptorLocation); >+ >+ String resourceProperties = pte.getAttributeNS(WsdmConstants.WSRP_NS, >+ RESOURCE_PROPERTIES_ELEMENT_KEY); >+ if (resourceProperties == null || resourceProperties.equals("")) >+ WsdmToolingLog.logMessage(Messages.NO_RP_ATTRIBUTE_WARN_); >+ else >+ map.put(RESOURCE_PROPERTIES_ELEMENT_KEY, resourceProperties); >+ >+ return map; >+ } >+ >+ /** >+ * Returns the MetadataMap from WSDL port type.<br> >+ * This map contain values for resource properties, metadatadescriptor and >+ * metadatadescriptorlocation. >+ */ >+ public static Map getMetadataFromPortType(Definition wsdlDefinition) >+ { >+ Map map = new HashMap(); >+ Element wsdlElement = wsdlDefinition.getElement(); >+ >+ NodeList nlpt = wsdlElement.getElementsByTagNameNS( >+ WsdlConstants.WSDL_NAMESPACE_URI, "portType"); >+ Element pte = (Element) nlpt.item(0); >+ if (pte == null) >+ { >+ // Don't log message in Error log it will go to problems view while >+ // validating mcap files >+ // WsdmToolingLog.logWarning(Messages.PORT_TYPE_NOT_FOUND_ERROR_); >+ return null; >+ } >+ >+ String metadataDescriptor = pte.getAttributeNS(WsdmConstants.WSRMD_NS, >+ METADATA_DESCRIPTOR_KEY); >+ if (metadataDescriptor == null || metadataDescriptor.equals("")) >+ { >+ metadataDescriptor = null; >+ // Don't log message in Error log it will go to problems view while >+ // validating mcap files >+ // WsdmToolingLog.logWarning(Messages.NO_METADESCRIPTOR_WARN_); >+ } >+ >+ String metadataDescriptorLocation = pte.getAttributeNS( >+ WsdmConstants.WSRMD_NS, METADATA_DESCRIPTOR_LOCATION_KEY); >+ if (metadataDescriptorLocation == null >+ || metadataDescriptorLocation.equals("")) >+ { >+ metadataDescriptorLocation = null; >+ // Don't log message in Error log it will go to problems view while >+ // validating mcap files >+ // WsdmToolingLog.logWarning(Messages.NO_METADESCRIPTOR_LOCATION_WARN_); >+ } >+ >+ String resourceProperties = pte.getAttributeNS(WsdmConstants.WSRP_NS, >+ RESOURCE_PROPERTIES_ELEMENT_KEY); >+ if (resourceProperties == null || resourceProperties.equals("")) >+ { >+ resourceProperties = null; >+ // Don't log message in Error log it will go to problems view while >+ // validating mcap files >+ // WsdmToolingLog.logWarning(Messages.NO_RP_ATTRIBUTE_WARN_); >+ } >+ >+ map.put(METADATA_DESCRIPTOR_KEY, metadataDescriptor); >+ map.put(METADATA_DESCRIPTOR_LOCATION_KEY, metadataDescriptorLocation); >+ map.put(RESOURCE_PROPERTIES_ELEMENT_KEY, resourceProperties); >+ >+ return map; >+ } >+ >+ /** >+ * Returns the WSDLFileLocation from WSDL Definition. >+ */ >+ public static String getWSDLFileLocation(Definition definition) >+ { >+ if (definition.getLocation() != null >+ && !definition.getLocation().equals("")) >+ return definition.getLocation(); >+ Resource resource = definition.eResource(); >+ if (resource == null) >+ { >+ WsdmToolingLog.logWarning(Messages.IMPROPER_WSDL_FILE_ERROR_); >+ return null; >+ } >+ URI uri = resource.getURI(); >+ if (uri == null) >+ { >+ WsdmToolingLog.logWarning(Messages.IMPROPER_WSDL_FILE_ERROR_); >+ return null; >+ } >+ return uri.toString(); >+ } >+ >+ /** >+ * Creates or return existing prefix. If the passed newPrefix is null, the >+ * it generates a unique prefix for the namespace. >+ */ >+ public static String createOrFindPrefix(Definition definition, >+ String namespace, String newPrefix) >+ { >+ String prefix = getPrefix(definition, namespace); >+ if (prefix != null) >+ return prefix; >+ if (newPrefix != null) >+ definition.addNamespace(newPrefix, namespace); >+ else >+ { >+ newPrefix = generateNewPrefix(definition); >+ definition.addNamespace(newPrefix, namespace); >+ } >+ return newPrefix; > } >- return wsdlLocation; >- } >-} > >+ private static String generateNewPrefix(Definition definition) >+ { >+ int count = 0; >+ String prefix = "pfx" + count; >+ while (isPrefixDefined(definition, prefix)) >+ { >+ prefix = "pfx" + count++; >+ } >+ return prefix; >+ } > >-class CustomWSDLResourceFactoryImpl extends ResourceFactoryImpl >-{ >- public CustomWSDLResourceFactoryImpl() >- { >- } >+ private static boolean isPrefixDefined(Definition definition, String prefix) >+ { >+ String[] namespaces = getAllDefinedNamespaces(definition); >+ for (int i = 0; i < namespaces.length; i++) >+ { >+ String pfx = getPrefix(definition, namespaces[i]); >+ if (pfx.equals(prefix)) >+ return true; >+ } >+ return false; >+ } > >- public Resource createResource(URI uri) >- { >- Resource result = new WSDLResourceImpl(uri); >- return result; >- } >+ /** >+ * Returns all the namespaces defined in the WSDL file. >+ */ >+ public static String[] getAllDefinedNamespaces(Definition definition) >+ { >+ List namespaces = new ArrayList(); >+ NamedNodeMap map = definition.getElement().getAttributes(); >+ for (int i = 0; i < map.getLength(); i++) >+ { >+ if (map.item(i) instanceof Attr) >+ { >+ Attr attribute = (Attr) map.item(i); >+ if (attribute.getNodeName().startsWith("xmlns:")) >+ { >+ String ns = attribute.getNodeValue(); >+ namespaces.add(ns); >+ } >+ } >+ } >+ return (String[]) namespaces.toArray(new String[namespaces.size()]); >+ } >+ >+ /** >+ * Returns the fault name of given faultElement. >+ */ >+ public static String getFaultType(XSDElementDeclaration faultElement) >+ { >+ String default_type = faultElement.getName(); >+ XSDTypeDefinition typeDef = faultElement.getTypeDefinition(); >+ if (typeDef == null) >+ return default_type; >+ if (!(typeDef instanceof XSDComplexTypeDefinition)) >+ return default_type; >+ XSDComplexTypeDefinition complexTypeDef = (XSDComplexTypeDefinition) typeDef; >+ XSDDerivationMethod derivationMethod = complexTypeDef >+ .getDerivationMethod(); >+ if (derivationMethod == null) >+ return default_type; >+ if (!derivationMethod.equals(XSDDerivationMethod.EXTENSION_LITERAL)) >+ return default_type; >+ XSDTypeDefinition baseTypeDef = complexTypeDef.getBaseTypeDefinition(); >+ if (baseTypeDef == null) >+ return default_type; >+ if (!(baseTypeDef instanceof XSDSimpleTypeDefinition)) >+ return default_type; >+ XSDSimpleTypeDefinition simpleBaseTypeDef = (XSDSimpleTypeDefinition) baseTypeDef; >+ return simpleBaseTypeDef.getName(); >+ } >+ >+ /** >+ * Returns the XSD fault elements of given wsdl operation. >+ */ >+ public static List getOperationFaultElements(Operation operation) >+ { >+ List retVal = new ArrayList(); >+ List faults = operation.getEFaults(); >+ for (int i = 0; i < faults.size(); i++) >+ { >+ Fault fault = (Fault) faults.get(i); >+ XSDElementDeclaration faultElement = getFaultElement(fault); >+ if (faultElement != null) >+ retVal.add(faultElement); >+ } >+ return retVal; >+ } >+ >+ /** >+ * Retruns the XSD fault elements of given wsdl fault. >+ */ >+ public static XSDElementDeclaration getFaultElement(Fault fault) >+ { >+ Message msg = fault.getEMessage(); >+ Part part_0 = (Part) msg.getEParts().get(0); >+ XSDElementDeclaration element = part_0.getElementDeclaration(); >+ return element; >+ } >+ >+ /** >+ * Returns the message which contains the given XSDElementDeclaration. >+ */ >+ public static Message getMessage(Definition definition, >+ XSDElementDeclaration element) >+ { >+ List msgs = definition.getEMessages(); >+ for (int i = 0; i < msgs.size(); i++) >+ { >+ Message msg = (Message) msgs.get(i); >+ Part part = getPart(msg, element); >+ if (part != null) >+ return msg; >+ } >+ return null; >+ } >+ >+ private static Part getPart(Message msg, XSDElementDeclaration element) >+ { >+ List parts = msg.getEParts(); >+ for (int i = 0; i < parts.size(); i++) >+ { >+ Part part = (Part) parts.get(i); >+ XSDElementDeclaration partElement = part.getElementDeclaration(); >+ if (element.equals(partElement)) >+ return part; >+ } >+ return null; >+ } >+ >+ /** >+ * Returns the Fault of given Message. >+ */ >+ public static Fault getFault(Operation operation, Message message) >+ { >+ List faults = operation.getEFaults(); >+ for (int i = 0; i < faults.size(); i++) >+ { >+ Fault fault = (Fault) faults.get(i); >+ Message msg = fault.getEMessage(); >+ if (message.equals(msg)) >+ return fault; >+ } >+ return null; >+ } >+ >+ /** >+ * Returns the name of WSDL Definition. >+ */ >+ public static String getName(Definition wsdlDef) >+ { >+ return wsdlDef.getQName().getLocalPart(); >+ } >+ >+ /** >+ * Create a new WSDL Import element inside given Definition. If imported >+ * namespace or wsdlLocation is null then it does nothing. If imported >+ * namespace is already imported in one of the WSDL Import element of the >+ * WSDL then it does nothing. >+ * >+ * @param definition >+ * Given WSDL definition inside which this new WSDL Import >+ * element will be added. >+ * >+ * @param namespace >+ * Namespace to be imported. >+ * >+ * @param wsdlLocation >+ * WSDL location to be imported. >+ */ >+ public static void createWSDLImport(Definition definition, >+ String namespace, String wsdlLocation) >+ { >+ if (namespace == null || wsdlLocation == null) >+ return; >+ /* >+ * if (definition.getTargetNamespace().equals(namespace)) return; >+ */ >+ if (!isImportNSExists(definition, namespace)) >+ { >+ Import wsdlImport = WSDLFactory.eINSTANCE.createImport(); >+ wsdlImport.setEnclosingDefinition(definition); >+ wsdlImport.setEDefinition(definition); >+ wsdlImport.setLocationURI(wsdlLocation); >+ wsdlImport.setNamespaceURI(namespace); >+ definition.addImport(wsdlImport); >+ createOrFindPrefix(definition, namespace, null); >+ } >+ } >+ >+ /** >+ * Check if perticular import already exists in given WSDL definition. >+ */ >+ public static boolean isImportNSExists(Definition definition, >+ String namespace) >+ { >+ List imports = definition.getEImports(); >+ for (int i = 0; i < imports.size(); i++) >+ { >+ Import wsdlImport = (Import) imports.get(i); >+ if (wsdlImport.getNamespaceURI().equals(namespace)) >+ return true; >+ } >+ return false; >+ } >+ >+ /** >+ * Returns the absolute path of given WSDL defintion in the local file >+ * system. >+ * >+ * @throws CoreException >+ */ >+ public static String getLocalSystemWSDLLocation(Definition definition) >+ throws CoreException >+ { >+ String uriLocation = getWSDLFileLocation(definition); >+ String wsdlLocation = uriLocation; >+ try >+ { >+ IFile wsdlFile = EclipseUtils.getIFile(uriLocation); >+ wsdlLocation = wsdlFile.getLocation().toString(); >+ wsdlLocation = EclipseUtils.replaceAll(wsdlLocation, '\\', '/'); >+ } catch (CoreException e) >+ { >+ WsdmToolingLog >+ .logError( >+ NLS >+ .bind( >+ org.eclipse.tptp.wsdm.tooling.nls.messages.capability.property.internal.Messages.FAILED_TO_FIND_LOCATION_FOR_XSD_ERROR_, >+ uriLocation), e); >+ throw e; >+ } >+ return wsdlLocation; >+ } > } > >+class CustomWSDLResourceFactoryImpl extends ResourceFactoryImpl >+{ >+ public CustomWSDLResourceFactoryImpl() >+ { >+ } > >+ public Resource createResource(URI uri) >+ { >+ Resource result = new WSDLResourceImpl(uri); >+ return result; >+ } >+} >Index: src/org/eclipse/tptp/wsdm/tooling/util/internal/PropertyMetaDataDescriptor.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/util/internal/PropertyMetaDataDescriptor.java >diff -N src/org/eclipse/tptp/wsdm/tooling/util/internal/PropertyMetaDataDescriptor.java >--- src/org/eclipse/tptp/wsdm/tooling/util/internal/PropertyMetaDataDescriptor.java 9 Jan 2007 19:52:24 -0000 1.6 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,319 +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.util.internal; >- >-import java.util.ArrayList; >-import java.util.Iterator; >-import java.util.LinkedList; >-import java.util.List; >- >-import org.eclipse.core.resources.IFile; >-import org.eclipse.core.runtime.CoreException; >-import org.eclipse.core.runtime.IProgressMonitor; >-import org.eclipse.emf.common.util.EMap; >-import org.eclipse.emf.ecore.EStructuralFeature; >-import org.eclipse.emf.ecore.resource.ResourceSet; >-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; >-import org.eclipse.emf.ecore.util.BasicExtendedMetaData; >-import org.eclipse.emf.ecore.util.BasicFeatureMap; >-import org.eclipse.emf.ecore.util.ExtendedMetaData; >-import org.eclipse.emf.ecore.util.FeatureMap; >-import org.eclipse.emf.ecore.util.FeatureMapUtil; >-import org.eclipse.emf.ecore.xml.type.AnyType; >-import org.eclipse.emf.ecore.xml.type.XMLTypeFactory; >-import org.eclipse.emf.ecore.xml.type.internal.QName; >-import org.eclipse.osgi.util.NLS; >-import org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability; >-import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.internal.Messages; >-import org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.DocumentRoot; >-import org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.InitialValuesType; >-import org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.MetadataDescriptorType; >-import org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.ModifiabilityType; >-import org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.MutabilityType; >-import org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.PropertyType; >-import org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.MetadataDescriptorFactory; >-import org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.impl.MetadataDescriptorFactoryImpl; >- >-/** >- * >- * This class will worked as a wrapper class for the RMD defined for a capability. >- * >- */ >- >-public class PropertyMetaDataDescriptor >-{ >- >- private ExtendedMetaData _extendedMetaData; >- >- private DocumentRoot _root; >- >- private EStructuralFeature esfWSDM_Capability; >- >- private MetadataDescriptorFactory _rmdFactory = new MetadataDescriptorFactoryImpl(); >- >- private String _metadataDescriptorName; >- >- private MetadataDescriptorType _metadataDescriptor; >- >- public PropertyMetaDataDescriptor(DocumentRoot root, Capability capability) >- { >- this(root, capability, capability.getName() + "Descriptor"); >- } >- >- public PropertyMetaDataDescriptor(DocumentRoot root, Capability capability, >- String metadataDescriptorName) >- { >- _root = root; >- if (metadataDescriptorName == null) >- _metadataDescriptorName = capability.getName() + "Descriptor"; >- _metadataDescriptorName = metadataDescriptorName; >- _extendedMetaData = createExtendedMetaData(); >- if (_root != null) >- _metadataDescriptor = getMetadataDescriptorType(); >- this.esfWSDM_Capability = _extendedMetaData.demandFeature( >- WsdmConstants.MUWS_P2_NS, "Capability", true); >- } >- >- private ExtendedMetaData createExtendedMetaData() >- { >- ResourceSet resourceSet = new ResourceSetImpl(); >- ExtendedMetaData extendedMetaData = new BasicExtendedMetaData( >- resourceSet.getPackageRegistry()); >- return extendedMetaData; >- } >- >- private PropertyType[] getAllPropertyTypes() >- { >- List capabilityProps = new LinkedList(); >- List propList = _metadataDescriptor.getProperty(); >- for (int i = 0; i < propList.size(); i++) >- { >- PropertyType property = (PropertyType) propList.get(i); >- capabilityProps.add(property); >- } >- return (PropertyType[]) capabilityProps.toArray(new PropertyType[0]); >- } >- >- public MetadataDescriptorType getMetadataDescriptorType() >- { >- List descriptors = _root.getDefinitions().getMetadataDescriptor(); >- for (int i = 0; i < descriptors.size(); i++) >- { >- MetadataDescriptorType mdtVal = (MetadataDescriptorType) descriptors >- .get(i); >- if (mdtVal.getName().equals(_metadataDescriptorName)) >- return mdtVal; >- } >- WsdmToolingLog.logWarning(NLS.bind(Messages.METADESCRIPTOR_TYPE_NOT_FOUND_WARN_,_metadataDescriptorName)); >- return null; >- } >- >- public DocumentRoot getDocumentRoot() >- { >- return _root; >- } >- >- public String getPrefix(String namespace) >- { >- if (namespace == null) >- return null; >- EMap map = _root.getXMLNSPrefixMap(); >- Iterator keyIt = map.keySet().iterator(); >- Iterator valuesIt = map.values().iterator(); >- while (valuesIt.hasNext()) >- { >- String ns = (String) valuesIt.next(); >- String prefix = (String) keyIt.next(); >- if (ns.equals(namespace)) >- return prefix; >- } >- return null; >- } >- >- public String getOrCreatePrefix(String namespace) >- { >- String prefix = getPrefix(namespace); >- if (prefix != null) >- return prefix; >- String newPrefix = generateNewPrefix(); >- _root.getXMLNSPrefixMap().put(newPrefix, namespace); >- return newPrefix; >- } >- >- private String generateNewPrefix() >- { >- int count = 0; >- while (isPrefixExists("pfx" + count)) >- count++; >- return "pfx" + count; >- } >- >- private boolean isPrefixExists(String prefix) >- { >- EMap map = _root.getXMLNSPrefixMap(); >- Iterator keyIt = map.keySet().iterator(); >- while (keyIt.hasNext()) >- { >- String pfx = (String) keyIt.next(); >- if (pfx.equals(prefix)) >- return true; >- } >- return false; >- } >- >- public List getTopicSpaces() >- { >- List topicSpaces = new ArrayList(); >- >- PropertyType topicExpProperty = getTopicExpressionProperty(); >- if (topicExpProperty == null) >- return topicSpaces; >- >- InitialValuesType intialValues = topicExpProperty.getInitialValues(); >- if (intialValues == null) >- return topicSpaces; >- >- FeatureMap map = intialValues.getAny(); >- Iterator it = map.valueListIterator(); >- MetaDataDescriptor2TopicSpace metaData2TopicSpace = new MetaDataDescriptor2TopicSpace( >- _root.getXMLNSPrefixMap()); >- while (it.hasNext()) >- { >- Object object = it.next(); >- if (object instanceof AnyType) >- { >- AnyType anyType = (AnyType) object; >- FeatureMap anyMap = anyType.getAny(); >- Iterator topicExpIt = anyMap.valueListIterator(); >- while (topicExpIt.hasNext()) >- { >- String topicExpression = (String) topicExpIt.next(); >- metaData2TopicSpace.addTopicExpression(topicExpression); >- } >- } >- } >- topicSpaces.addAll(metaData2TopicSpace.getTopicSpaces()); >- return topicSpaces; >- } >- >- public PropertyType getTopicExpressionProperty() >- { >- PropertyType topicExpressionProperty = getPropertyMetadata("TopicExpression", >- WsdmConstants.WSNT_NS); >- return topicExpressionProperty; >- } >- >- public PropertyType getPropertyMetadata(String name, String namespace) >- { >- List properties = _metadataDescriptor.getProperty(); >- for (int i = 0; i < properties.size(); i++) >- { >- PropertyType property = (PropertyType) properties.get(i); >- QName qname = (QName) property.getName(); >- if (qname.getLocalPart().equals(name) >- && qname.getNamespaceURI().equals(namespace)) >- return property; >- } >- return null; >- } >- >- public void saveTopicSpaces(List topicSpaces) >- { >- PropertyType topicExpressionProperty = getTopicExpressionProperty(); >- if (topicExpressionProperty != null) >- { >- InitialValuesType intialValues = _rmdFactory >- .createInitialValuesType(); >- // TODO Check null for InitialValuesType and if null create new InitialValuesType >- EMap nsMap = _root.getXMLNSPrefixMap(); >- TopicSpace2MetaDataDescriptor topicSpace2MetaData = new TopicSpace2MetaDataDescriptor( >- nsMap, topicSpaces); >- String[] topicExpressions = topicSpace2MetaData >- .getTopicExpressions(); >- FeatureMap fm = intialValues.getAny(); >- for (int i = 0; i < topicExpressions.length; i++) >- { >- EStructuralFeature esf = _extendedMetaData.demandFeature( >- WsdmConstants.WSNT_NS, "TopicExpression", true); >- AnyType atTopicExpression = XMLTypeFactory.eINSTANCE >- .createAnyType(); >- FeatureMapUtil.addText(atTopicExpression.getAny(), >- topicExpressions[i]); >- fm.add(esf, atTopicExpression); >- } >- topicExpressionProperty.setInitialValues(intialValues); >- } >- } >- >- public void save(IProgressMonitor monitor) >- { >- String rmdFileUri = _root.eResource().getURI().toString(); >- IFile rmdFile = null; >- try { >- rmdFile = EclipseUtils.getIFile(rmdFileUri); >- } catch (CoreException e) { >- e.printStackTrace(); >- } >- RmdUtils.serializeAndFormat(_root, rmdFile, monitor); >- } >- >- public PropertyType[] getPropertyTypes() >- { >- return getAllPropertyTypes(); >- } >- >- public void setDocumentRoot(DocumentRoot root) >- { >- _root = root; >- } >- >- public void setMetadataDescriptorType( >- MetadataDescriptorType metadataDescriptor) >- { >- _metadataDescriptor = metadataDescriptor; >- } >- >- public void setMetadataDescriptorName(String metadataDescriptorName) >- { >- _metadataDescriptorName = metadataDescriptorName; >- if (_metadataDescriptor != null) >- _metadataDescriptor.setName(metadataDescriptorName); >- } >- >- public PropertyType createNewPropertyType() >- { >- PropertyType propertyType = _rmdFactory.createPropertyType(); >- _metadataDescriptor.getProperty().add(propertyType); >- return propertyType; >- } >- >- public PropertyType createTopicExpressionProperty() >- { >- _root.getXMLNSPrefixMap().put("wsnt", WsdmConstants.WSNT_NS); >- PropertyType topicExp = _rmdFactory.createPropertyType(); >- topicExp.setModifiability(ModifiabilityType.READ_ONLY_LITERAL); >- topicExp.setMutability(MutabilityType.MUTABLE_LITERAL); >- topicExp.setName(new QName(WsdmConstants.WSNT_NS, "TopicExpression", >- "wsnt")); >- InitialValuesType initialValues = _rmdFactory.createInitialValuesType(); >- topicExp.setInitialValues(initialValues); >- >- FeatureMap fm = topicExp.getAny(); >- AnyType atCapability = XMLTypeFactory.eINSTANCE.createAnyType(); >- FeatureMapUtil.addText(atCapability.getAny(), WsdmConstants.WSNT_NS); >- fm.add(esfWSDM_Capability, atCapability); >- >- _metadataDescriptor.getProperty().add(topicExp); >- return topicExp; >- } >-} >Index: src/org/eclipse/tptp/wsdm/tooling/util/internal/MetaDataDescriptor2TopicSpace.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/util/internal/MetaDataDescriptor2TopicSpace.java >diff -N src/org/eclipse/tptp/wsdm/tooling/util/internal/MetaDataDescriptor2TopicSpace.java >--- src/org/eclipse/tptp/wsdm/tooling/util/internal/MetaDataDescriptor2TopicSpace.java 9 Jan 2007 19:52:24 -0000 1.3 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,207 +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.util.internal; >- >-import java.util.ArrayList; >-import java.util.List; >-import java.util.StringTokenizer; >- >-import org.eclipse.emf.common.util.EMap; >-import org.eclipse.tptp.wsdm.tooling.model.capabilities.Topic; >-import org.eclipse.tptp.wsdm.tooling.model.capabilities.TopicSpace; >- >-/** >- * >- * Populate capability topics from TopicExpression property.<br> >- * If RMD file has TopicExpression defined as <br><br> >- * >- * xmlns:topics1="http://w3.ibm.com/capabilities/WAS/Topics"<br> >- * >- * < wsnt:TopicExpression > topics1:RootTopic < /wsnt:TopicExpression ><br> >- * < wsnt:TopicExpression > topics1:RootTopic/ChildTopic < /wsnt:TopicExpression ><br><br> >- * >- * Then it will create in memory model for topics as<br><br> >- * >- * http://w3.ibm.com/capabilities/WAS (TopicNameSpace)<br> >- * |____RootTopic <br> >- * |______ChildTopic <br><br> >- * >- * @see #getTopicSpaces() >- * >- */ >- >-public class MetaDataDescriptor2TopicSpace >-{ >- >- private List _topicSpaces; >- >- private EMap _nsMap; >- >- /** >- * Creates the object of this class.<br> >- * Parameter passed is the map of the namespaces available in rmd file. >- */ >- public MetaDataDescriptor2TopicSpace(EMap nsMap) >- { >- _nsMap = nsMap; >- _topicSpaces = new ArrayList(); >- } >- >- /** >- * >- * @param topicExpression >- * Topic expression for which new topicSpace to be created. >- */ >- public void addTopicExpression(String topicExpression) >- { >- TopicSpace topicSpace = getTopicSpace(topicExpression); >- createTopic(topicSpace, topicExpression); >- } >- >- /** >- * >- * @return Topicspaces corresponding to topic expression property. >- */ >- public List getTopicSpaces() >- { >- return _topicSpaces; >- } >- >- private TopicSpace getTopicSpace(String topicExpression) >- { >- String prefix = topicExpression.substring(0, topicExpression >- .indexOf(':')); >- String namespace = (String) _nsMap.get(prefix); >- if (!isTopicSpaceCreated(namespace)) >- { >- TopicSpace topicSpace = TopicUtils.createNewTopicSpace(); >- topicSpace.setName(prefix); >- topicSpace.setNamespace(namespace); >- _topicSpaces.add(topicSpace); >- return topicSpace; >- } >- >- for (int i = 0; i < _topicSpaces.size(); i++) >- { >- TopicSpace topicSpace = (TopicSpace) _topicSpaces.get(i); >- if (topicSpace.getNamespace().equals(namespace)) >- return topicSpace; >- } >- >- return null; >- } >- >- private boolean isTopicSpaceCreated(String namespace) >- { >- for (int i = 0; i < _topicSpaces.size(); i++) >- { >- TopicSpace topicSpace = (TopicSpace) _topicSpaces.get(i); >- if (topicSpace.getNamespace().equals(namespace)) >- return true; >- } >- return false; >- } >- >- private void createTopic(TopicSpace topicSpace, String topicExpression) >- { >- String path = topicExpression >- .substring(topicExpression.indexOf(':') + 1); >- StringTokenizer tokenizer = new StringTokenizer(path, "/"); >- >- String rootTopicName = tokenizer.nextToken(); >- Topic parentTopic = null; >- if (!isTopicCreated(topicSpace, rootTopicName)) >- { >- parentTopic = createRootTopic(topicSpace, rootTopicName); >- } >- else >- { >- parentTopic = getRootTopic(topicSpace, rootTopicName); >- } >- >- while (tokenizer.hasMoreTokens()) >- { >- String childTopicName = tokenizer.nextToken(); >- if (!isTopicCreated(parentTopic, childTopicName)) >- { >- parentTopic = createChildTopic(parentTopic, childTopicName); >- } >- else >- { >- parentTopic = getChildTopic(parentTopic, childTopicName); >- } >- } >- } >- >- private boolean isTopicCreated(TopicSpace topicSpace, String rootTopicName) >- { >- for (int i = 0; i < topicSpace.getRootTopics().size(); i++) >- { >- Topic rootTopic = (Topic) topicSpace.getRootTopics().get(i); >- if (rootTopic.getName().equals(rootTopicName)) >- return true; >- } >- return false; >- } >- >- private boolean isTopicCreated(Topic parentTopic, String childTopicName) >- { >- for (int i = 0; i < parentTopic.getChildren().size(); i++) >- { >- Topic childTopic = (Topic) parentTopic.getChildren().get(i); >- if (childTopic.getName().equals(childTopicName)) >- return true; >- } >- return false; >- } >- >- private Topic createRootTopic(TopicSpace topicSpace, String rootTopicName) >- { >- Topic rootTopic = TopicUtils.createNewTopic(); >- rootTopic.setName(rootTopicName); >- rootTopic.setParent(null); >- topicSpace.getRootTopics().add(rootTopic); >- return rootTopic; >- } >- >- private Topic getRootTopic(TopicSpace topicSpace, String rootTopicName) >- { >- for (int i = 0; i < topicSpace.getRootTopics().size(); i++) >- { >- Topic rootTopic = (Topic) topicSpace.getRootTopics().get(i); >- if (rootTopic.getName().equals(rootTopicName)) >- return rootTopic; >- } >- return null; >- } >- >- private Topic createChildTopic(Topic topic, String childTopicName) >- { >- Topic childTopic = TopicUtils.createNewTopic(); >- childTopic.setName(childTopicName); >- childTopic.setParent(topic); >- topic.getChildren().add(childTopic); >- return childTopic; >- } >- >- private Topic getChildTopic(Topic parentTopic, String childTopicName) >- { >- for (int i = 0; i < parentTopic.getChildren().size(); i++) >- { >- Topic childTopic = (Topic) parentTopic.getChildren().get(i); >- if (childTopic.getName().equals(childTopicName)) >- return childTopic; >- } >- return null; >- } >-} >Index: src/org/eclipse/tptp/wsdm/tooling/util/internal/CapUtils.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.validation/src/org/eclipse/tptp/wsdm/tooling/util/internal/CapUtils.java,v >retrieving revision 1.6 >diff -u -r1.6 CapUtils.java >--- src/org/eclipse/tptp/wsdm/tooling/util/internal/CapUtils.java 9 Jan 2007 19:52:24 -0000 1.6 >+++ src/org/eclipse/tptp/wsdm/tooling/util/internal/CapUtils.java 20 Jan 2007 13:34:34 -0000 >@@ -13,6 +13,8 @@ > package org.eclipse.tptp.wsdm.tooling.util.internal; > > import java.io.IOException; >+import java.io.InputStream; >+import java.io.StringReader; > import java.io.StringWriter; > import java.lang.reflect.Method; > import java.util.ArrayList; >@@ -22,7 +24,9 @@ > import java.util.List; > import java.util.Map; > >-import org.apache.muse.util.xml.XmlUtils; >+import javax.xml.parsers.DocumentBuilder; >+import javax.xml.parsers.DocumentBuilderFactory; >+ > import org.apache.xml.serialize.OutputFormat; > import org.apache.xml.serialize.XMLSerializer; > import org.eclipse.core.resources.IFile; >@@ -46,459 +50,512 @@ > import org.w3c.dom.Document; > import org.w3c.dom.Element; > import org.w3c.dom.Text; >+import org.xml.sax.InputSource; > import org.xml.sax.SAXException; > > /** > * > * Utility class to handle different parts of capability. >- * >+ * > */ > > public class CapUtils > { > >- /** Includes all Java keywords, plus literals true/false/null */ >- private static final List JAVA_KEYWORDS = Arrays.asList(new String[] { >- "abstract", "continue", "for", "new", "switch", "assert", >- "default", "goto", "package", "synchronized", "boolean", "do", >- "if", "private", "this", "break", "double", "implements", >- "protected", "throw", "byte", "else", "import", "public", "throws", >- "case", "enum", "instanceof", "return", "transient", "catch", >- "extends", "int", "short", "try", "char", "final", "interface", >- "static", "void", "class", "finally", "long", "strictfp", >- "volatile", "const", "float", "native", "super", "while", "true", >- "false", "null" }); >- >- // This map will contain Capability URI as key and List of Capability WSDL Definition as value >- // all of which have the same capability uri >- private static Map standardCapabilityMap = null; >- >- // Capability operation name should not be conflicted with their super java implementation classes. >- private static Method[] abstractCapabilityMethods = new Method[0]; >- >- static{ >- try { >- Class abstractCapability = Class.forName("org.apache.muse.core.AbstractCapability"); >- abstractCapabilityMethods = abstractCapability.getMethods(); >- } catch (ClassNotFoundException e) { >- WsdmToolingLog.logError(e.getMessage(), e); >- } catch(SecurityException e) { >+ /** Includes all Java keywords, plus literals true/false/null */ >+ private static final List JAVA_KEYWORDS = Arrays.asList(new String[] { >+ "abstract", "continue", "for", "new", "switch", "assert", >+ "default", "goto", "package", "synchronized", "boolean", "do", >+ "if", "private", "this", "break", "double", "implements", >+ "protected", "throw", "byte", "else", "import", "public", "throws", >+ "case", "enum", "instanceof", "return", "transient", "catch", >+ "extends", "int", "short", "try", "char", "final", "interface", >+ "static", "void", "class", "finally", "long", "strictfp", >+ "volatile", "const", "float", "native", "super", "while", "true", >+ "false", "null" }); >+ >+ // This map will contain Capability URI as key and List of Capability WSDL >+ // Definition as value >+ // all of which have the same capability uri >+ private static Map standardCapabilityMap = null; >+ >+ // Capability operation name should not be conflicted with their super java >+ // implementation classes. >+ private static Method[] abstractCapabilityMethods = new Method[0]; >+ >+ static >+ { >+ try >+ { >+ Class abstractCapability = Class >+ .forName("org.apache.muse.core.AbstractCapability"); >+ abstractCapabilityMethods = abstractCapability.getMethods(); >+ } catch (ClassNotFoundException e) >+ { >+ WsdmToolingLog.logError(e.getMessage(), e); >+ } catch (SecurityException e) >+ { > WsdmToolingLog.logError(e.getMessage(), e); > } >- } >+ } > >- /** >- * This method will retun the root topic , provided any child topic or >- * root topic itself. Recursively find the root topic. >- */ >- public static Topic getRootTopic(Topic topic) >- { >- if (isRootTopic(topic)) >- return topic; >- Topic rootTopic = getRootTopic(topic.getParent()); >- return rootTopic; >- } >- >- /** >- * Return true if given topic is a root topic >- */ >- public static boolean isRootTopic(Topic topic) >- { >- if (topic.getParent() == null) >- return true; >- return false; >- } >- >- /** >- * Returns the capability name form qname. >- */ >- public static String getCapabilityNameFromQName(String qname) >- { >- int index = qname.lastIndexOf(':'); >- if (index != -1) >- { >- return qname.substring(index + 1); >- >- } >- return qname; >- } >- >- /** >- * Returns the capability prefix form qname. >- */ >- public static String getCapabilityPrefixFromQName(String qname) >- { >- int index = qname.lastIndexOf(':'); >- if (index != -1) >- { >- return qname.substring(0, index); >- } >- return null; >- } >- >- /** >- * Returns the namespace of given capability. >- */ >- public static String getNamespace(Capability cap) >- { >- String ns = cap.getNamespace(); >- if (ns == null) >- { >- WsdmToolingLog.logWarning(NLS.bind(Messages.CAPABILITY_HAS_NO_NS_WARN_,cap.getName())); >- return MrtUtils.createTempNamespace(); >- } >- >- return ns; >- } >- >- /** >- * Retruns the list of XSDSchemas that represents the container of properties of capability. >- */ >- public static List getPropertiesSchemas(Definition definition, >- XSDElementDeclaration resourcePropertyElement) >- { >- >- if (resourcePropertyElement == null) >- { >- WsdmToolingLog.logMessage(Messages.NULL_RESOURCE_PROPERTY_ELEMENT_ERROR_); >- return null; >- } >- >- List processedSchemas = new LinkedList(); >- >- if (resourcePropertyElement.getAnonymousTypeDefinition() == null) >- { >- XSDSchema[] schemas = WsdlUtils.getXSDSchemas(definition); >- if (schemas.length == 0) >- WsdmToolingLog.logWarning(Messages.NO_XSD_FOUND_IN_WSDL_INFO_); >- XSDSchema rpSchema = WsdlUtils.getSchema(definition, >- resourcePropertyElement.getTargetNamespace()); >- if (XsdUtils.hasIncludeXSD(rpSchema)) >- { >- XSDInclude include = XsdUtils.getFirstXSDInclude(rpSchema); >- processedSchemas.add(include.getResolvedSchema()); >- return processedSchemas; >- } >- else >- { >- processedSchemas.add(rpSchema); >+ /** >+ * This method will retun the root topic , provided any child topic or root >+ * topic itself. Recursively find the root topic. >+ */ >+ public static Topic getRootTopic(Topic topic) >+ { >+ if (isRootTopic(topic)) >+ return topic; >+ Topic rootTopic = getRootTopic(topic.getParent()); >+ return rootTopic; >+ } >+ >+ /** >+ * Return true if given topic is a root topic >+ */ >+ public static boolean isRootTopic(Topic topic) >+ { >+ if (topic.getParent() == null) >+ return true; >+ return false; >+ } >+ >+ /** >+ * Returns the capability name form qname. >+ */ >+ public static String getCapabilityNameFromQName(String qname) >+ { >+ int index = qname.lastIndexOf(':'); >+ if (index != -1) >+ { >+ return qname.substring(index + 1); >+ >+ } >+ return qname; >+ } >+ >+ /** >+ * Returns the capability prefix form qname. >+ */ >+ public static String getCapabilityPrefixFromQName(String qname) >+ { >+ int index = qname.lastIndexOf(':'); >+ if (index != -1) >+ { >+ return qname.substring(0, index); >+ } >+ return null; >+ } >+ >+ /** >+ * Returns the namespace of given capability. >+ */ >+ public static String getNamespace(Capability cap) >+ { >+ String ns = cap.getNamespace(); >+ if (ns == null) >+ { >+ WsdmToolingLog.logWarning(NLS.bind( >+ Messages.CAPABILITY_HAS_NO_NS_WARN_, cap.getName())); >+ return MrtUtils.createTempNamespace(); >+ } >+ >+ return ns; >+ } >+ >+ /** >+ * Retruns the list of XSDSchemas that represents the container of >+ * properties of capability. >+ */ >+ public static List getPropertiesSchemas(Definition definition, >+ XSDElementDeclaration resourcePropertyElement) >+ { >+ >+ if (resourcePropertyElement == null) >+ { >+ WsdmToolingLog >+ .logMessage(Messages.NULL_RESOURCE_PROPERTY_ELEMENT_ERROR_); >+ return null; >+ } >+ >+ List processedSchemas = new LinkedList(); >+ >+ if (resourcePropertyElement.getAnonymousTypeDefinition() == null) >+ { >+ XSDSchema[] schemas = WsdlUtils.getXSDSchemas(definition); >+ if (schemas.length == 0) >+ WsdmToolingLog.logWarning(Messages.NO_XSD_FOUND_IN_WSDL_INFO_); >+ XSDSchema rpSchema = WsdlUtils.getSchema(definition, >+ resourcePropertyElement.getTargetNamespace()); >+ if (XsdUtils.hasIncludeXSD(rpSchema)) >+ { >+ XSDInclude include = XsdUtils.getFirstXSDInclude(rpSchema); >+ processedSchemas.add(include.getResolvedSchema()); >+ return processedSchemas; >+ } >+ else >+ { >+ processedSchemas.add(rpSchema); >+ return processedSchemas; >+ } >+ } >+ >+ XSDComplexTypeDefinition typeDef = (XSDComplexTypeDefinition) resourcePropertyElement >+ .getAnonymousTypeDefinition(); >+ XSDModelGroup modelGroup = XsdUtils.getXSDModelGroup(typeDef); >+ XSDElementDeclaration[] elementRefs = XsdUtils >+ .getElementDeclarations(modelGroup); >+ for (int i = 0; i < elementRefs.length; i++) >+ { >+ if (XsdUtils.isReferencedElement(elementRefs[i])) >+ { >+ WsdlElementResolver resolver = new WsdlElementResolver( >+ definition, resourcePropertyElement, elementRefs[i]); >+ XSDElementDeclaration resolvedElement = resolver.resolve(); >+ if (resolvedElement != null) >+ { >+ XSDSchema propSchema = resolvedElement.getSchema(); >+ if (!processedSchemas.contains(propSchema)) >+ processedSchemas.add(propSchema); >+ } >+ } >+ } >+ >+ if (processedSchemas.size() != 0) >+ return processedSchemas; >+ >+ processedSchemas.add(resourcePropertyElement.getSchema()); > return processedSchemas; >- } > } > >- XSDComplexTypeDefinition typeDef = (XSDComplexTypeDefinition) resourcePropertyElement >- .getAnonymousTypeDefinition(); >- XSDModelGroup modelGroup = XsdUtils.getXSDModelGroup(typeDef); >- XSDElementDeclaration[] elementRefs = XsdUtils >- .getElementDeclarations(modelGroup); >- for (int i = 0; i < elementRefs.length; i++) >- { >- if (XsdUtils.isReferencedElement(elementRefs[i])) >- { >- WsdlElementResolver resolver = new WsdlElementResolver( >- definition, resourcePropertyElement, elementRefs[i]); >- XSDElementDeclaration resolvedElement = resolver.resolve(); >- if (resolvedElement != null) >- { >- XSDSchema propSchema = resolvedElement.getSchema(); >- if (!processedSchemas.contains(propSchema)) >- processedSchemas.add(propSchema); >- } >- } >- } >- >- if (processedSchemas.size() != 0) >- return processedSchemas; >- >- processedSchemas.add(resourcePropertyElement.getSchema()); >- return processedSchemas; >- } >- >- /** >- * Returns the minoccurs of property. >- */ >- public static int getMinOccurs( >- XSDElementDeclaration resourcePropertyElement, >- XSDElementDeclaration property) >- { >- XSDElementDeclaration propertyRef = getPropertyRef( >- resourcePropertyElement, property); >- if (propertyRef == null) >- { >- WsdmToolingLog.logWarning(NLS.bind(Messages.REFERENCE_NOT_FOUND_ERROR_, property.getName())); >- return 0; >- } >- if (propertyRef.eContainer() instanceof XSDParticle) >- { >- XSDParticle xsdParticle = (XSDParticle) propertyRef.eContainer(); >- return xsdParticle.getMinOccurs(); >- } >- return 0; >- } >- >- /** >- * Returns the maxoccurs of property. >- */ >- public static int getMaxOccurs( >- XSDElementDeclaration resourcePropertyElement, >- XSDElementDeclaration property) >- { >- XSDElementDeclaration propertyRef = getPropertyRef( >- resourcePropertyElement, property); >- if (propertyRef == null) >- { >- WsdmToolingLog.logWarning(NLS.bind(Messages.REFERENCE_NOT_FOUND_ERROR_, property.getName())); >- return 0; >- } >- if (propertyRef.eContainer() instanceof XSDParticle) >- { >- XSDParticle xsdParticle = (XSDParticle) propertyRef.eContainer(); >- return xsdParticle.getMaxOccurs(); >- } >- return 0; >- } >- >- private static XSDElementDeclaration getPropertyRef( >- XSDElementDeclaration resourcePropertyElement, >- XSDElementDeclaration property) >- { >- XSDComplexTypeDefinition typeDef = (XSDComplexTypeDefinition) resourcePropertyElement >- .getAnonymousTypeDefinition(); >- XSDModelGroup modelGroup = XsdUtils.getXSDModelGroup(typeDef); >- XSDElementDeclaration[] elementRefs = XsdUtils >- .getElementDeclarations(modelGroup); >- for (int i = 0; i < elementRefs.length; i++) >- { >- if (XsdUtils.isReferencedElement(elementRefs[i])) >- { >- XSDElementDeclaration element = elementRefs[i] >- .getResolvedElementDeclaration(); >- if (element.getName().equals(property.getName()) >- && element.getTargetNamespace().equals( >- property.getTargetNamespace())) >- return elementRefs[i]; >- } >- } >- return null; >- } >- >- /** >- * Returns the properties resolved from resourcePropertyElement. >- */ >- public static XSDElementDeclaration[] getResolvedProperties( >- Definition definition, XSDElementDeclaration resourcePropertyElement) >- { >- List properties = new LinkedList(); >- >- if (resourcePropertyElement.getAnonymousTypeDefinition() == null) >- { >- return new XSDElementDeclaration[0]; >- } >- >- XSDComplexTypeDefinition typeDef = (XSDComplexTypeDefinition) resourcePropertyElement >- .getAnonymousTypeDefinition(); >- XSDModelGroup modelGroup = XsdUtils.getXSDModelGroup(typeDef); >- XSDElementDeclaration[] elementRefs = XsdUtils >- .getElementDeclarations(modelGroup); >- for (int i = 0; i < elementRefs.length; i++) >- { >- if (XsdUtils.isReferencedElement(elementRefs[i])) >- { >- WsdlElementResolver resolver = new WsdlElementResolver( >- definition, resourcePropertyElement, elementRefs[i]); >- XSDElementDeclaration resolvedElement = resolver.resolve(); >- if (resolvedElement != null) >- properties.add(resolvedElement); >- } >- } >- >- return (XSDElementDeclaration[]) properties >- .toArray(new XSDElementDeclaration[0]); >- } >- >- /** >- * Returns string of SerializedDocument. >- */ >- public static String getSerializedDocument(String string) >- { >- Document document = parseToDOM(string); >- String serialized = prettySerializeDocument(document); >- return serialized; >- } >- >- /** >- * Parses the given string to DOM document. >- */ >- public static Document parseToDOM(String xmlString) >- { >- Document document = null; >- try >- { >- document = XmlUtils.createDocument(xmlString); >- } catch (IOException ioe) >- { >- WsdmToolingLog.logError(Messages.CANT_PARSE_XML_ERROR_, ioe); >- return null; >- } catch (SAXException se) >- { >- WsdmToolingLog.logError(Messages.CANT_PARSE_XML_ERROR_, se); >- return null; >- } >- document.normalize(); >- return document; >- } >- >- /** >- * Prepares SerializeDocument. >- */ >- public static String prettySerializeDocument(Document doc) >- { >- OutputFormat format = new OutputFormat(); >- format.setPreserveSpace(false); >- format.setIndenting(true); >- format.setIndent(2); >- format.setLineWidth(72); >- format.setLineSeparator(System.getProperty("line.separator")); >- StringWriter writer = new StringWriter(); >- XMLSerializer serializer = new XMLSerializer(writer, format); >- try >- { >- serializer.serialize(doc); >- } catch (IOException ioe) >- { >- WsdmToolingLog.logError(Messages.CANT_SERIALIZE_DOCUMENT_ERROR_, ioe); >- } >- return writer.getBuffer().toString(); >- } >- >- /** >- * Returns the instances of property of the given name. >- */ >- public static int getInstancesOfProperty(Capability model, String propName) >- { >- int counter = 0; >- EList propList = model.getProperties(); >- for (int i = 0; i < propList.size(); i++) >- { >- Property property = (Property) propList.get(i); >- String name = XsdUtils.getName(property.getElement()); >- if (name.equals(propName)) >- counter++; >- } >- return counter; >- } >- >- /** >- * Returns the instances of operation of the given name. >- */ >- public static int getInstancesOfOperation(Capability model, String opName) >- { >- int counter = 0; >- EList opList = model.getOperations(); >- for (int i = 0; i < opList.size(); i++) >- { >- Operation op = (Operation) opList.get(i); >- if (op.getName().equals(opName)) >- counter++; >- } >- return counter; >- } >- >- /** >- * Returns the instances of parameter of the given name. >- */ >- public static int getInstancesOfParameter(Operation operation, >- String paramName) >- { >- int counter = 0; >- XSDElementDeclaration[] params = WsdlUtils >- .getOperationParams(operation); >- for (int i = 0; i < params.length; i++) >- { >- if (params[i].getName().equals(paramName)) >- counter++; >- } >- return counter; >- } >- >- /** >- * >- * Validate whether given string is valid identifier or not >- * NOTE : Fix for defect [#47609] Validation needed on text fields in editors >- */ >- public static String validateJavaIdentifier(String name) >- { >- // A Java identifier begins with a JavaLetter, followed by 0..n >- // JavaLetterOrDigit, >- // but MUST NOT be a Java Keyword, true, false, or null >- >- if (name.length() == 0) >- { >- return Messages.EMPTY_NAME_ERROR_; >- } >- >- if (!Character.isJavaIdentifierStart(name.charAt(0))) >- { >- return NLS.bind(Messages.INVALID_NAME_ERROR_, name); >- } >- >- for (int i = 1; i < name.length(); i++) >- { >- if (!Character.isJavaIdentifierPart(name.charAt(i))) >- { >- return NLS.bind(Messages.INVALID_NAME_ERROR_, name); >- } >- } >- >- if (JAVA_KEYWORDS.contains(name)) >- { >- return NLS.bind(Messages.INVALID_NAME_JAVA_KEYWORD_ERROR_, name); >- } >- return null; >- } >- >- /** >- * Returns the property of the given name. >- */ >- public static Property getProperty(Capability capability,String namespace, String propertyName) >- { >- List propList = capability.getProperties(); >- for (int i = 0; i < propList.size(); i++) >- { >- Property property = (Property) propList.get(i); >- XSDElementDeclaration propElement = property.getElement(); >- String name = XsdUtils.getName(propElement); >- if (propElement.getTargetNamespace().equals(namespace) && name.equals(propertyName)) >- return property; >- } >- return null; >- } >- >- /** >- * Returns the name of the property. >- */ >- public static String getName(Property property) >- { >- return XsdUtils.getName(property.getElement()); >- } >- >- /** >- * Returns the capability DescriptionNode. >- */ >- public static Text getDescriptionNode(Definition definition) { >+ /** >+ * Returns the minoccurs of property. >+ */ >+ public static int getMinOccurs( >+ XSDElementDeclaration resourcePropertyElement, >+ XSDElementDeclaration property) >+ { >+ XSDElementDeclaration propertyRef = getPropertyRef( >+ resourcePropertyElement, property); >+ if (propertyRef == null) >+ { >+ WsdmToolingLog.logWarning(NLS.bind( >+ Messages.REFERENCE_NOT_FOUND_ERROR_, property.getName())); >+ return 0; >+ } >+ if (propertyRef.eContainer() instanceof XSDParticle) >+ { >+ XSDParticle xsdParticle = (XSDParticle) propertyRef.eContainer(); >+ return xsdParticle.getMinOccurs(); >+ } >+ return 0; >+ } >+ >+ /** >+ * Returns the maxoccurs of property. >+ */ >+ public static int getMaxOccurs( >+ XSDElementDeclaration resourcePropertyElement, >+ XSDElementDeclaration property) >+ { >+ XSDElementDeclaration propertyRef = getPropertyRef( >+ resourcePropertyElement, property); >+ if (propertyRef == null) >+ { >+ WsdmToolingLog.logWarning(NLS.bind( >+ Messages.REFERENCE_NOT_FOUND_ERROR_, property.getName())); >+ return 0; >+ } >+ if (propertyRef.eContainer() instanceof XSDParticle) >+ { >+ XSDParticle xsdParticle = (XSDParticle) propertyRef.eContainer(); >+ return xsdParticle.getMaxOccurs(); >+ } >+ return 0; >+ } >+ >+ private static XSDElementDeclaration getPropertyRef( >+ XSDElementDeclaration resourcePropertyElement, >+ XSDElementDeclaration property) >+ { >+ XSDComplexTypeDefinition typeDef = (XSDComplexTypeDefinition) resourcePropertyElement >+ .getAnonymousTypeDefinition(); >+ XSDModelGroup modelGroup = XsdUtils.getXSDModelGroup(typeDef); >+ XSDElementDeclaration[] elementRefs = XsdUtils >+ .getElementDeclarations(modelGroup); >+ for (int i = 0; i < elementRefs.length; i++) >+ { >+ if (XsdUtils.isReferencedElement(elementRefs[i])) >+ { >+ XSDElementDeclaration element = elementRefs[i] >+ .getResolvedElementDeclaration(); >+ if (element.getName().equals(property.getName()) >+ && element.getTargetNamespace().equals( >+ property.getTargetNamespace())) >+ return elementRefs[i]; >+ } >+ } >+ return null; >+ } >+ >+ /** >+ * Returns the properties resolved from resourcePropertyElement. >+ */ >+ public static XSDElementDeclaration[] getResolvedProperties( >+ Definition definition, XSDElementDeclaration resourcePropertyElement) >+ { >+ List properties = new LinkedList(); >+ >+ if (resourcePropertyElement.getAnonymousTypeDefinition() == null) >+ { >+ return new XSDElementDeclaration[0]; >+ } >+ >+ XSDComplexTypeDefinition typeDef = (XSDComplexTypeDefinition) resourcePropertyElement >+ .getAnonymousTypeDefinition(); >+ XSDModelGroup modelGroup = XsdUtils.getXSDModelGroup(typeDef); >+ XSDElementDeclaration[] elementRefs = XsdUtils >+ .getElementDeclarations(modelGroup); >+ for (int i = 0; i < elementRefs.length; i++) >+ { >+ if (XsdUtils.isReferencedElement(elementRefs[i])) >+ { >+ WsdlElementResolver resolver = new WsdlElementResolver( >+ definition, resourcePropertyElement, elementRefs[i]); >+ XSDElementDeclaration resolvedElement = resolver.resolve(); >+ if (resolvedElement != null) >+ properties.add(resolvedElement); >+ } >+ } >+ >+ return (XSDElementDeclaration[]) properties >+ .toArray(new XSDElementDeclaration[0]); >+ } >+ >+ /** >+ * Returns string of SerializedDocument. >+ */ >+ public static String getSerializedDocument(String string) >+ { >+ Document document = parseToDOM(string); >+ String serialized = documentToString(document); >+ return serialized; >+ } >+ >+ public static Document parseToDOM(String xmlString) >+ { >+ Document document = null; >+ try >+ { >+ document = createDocument(xmlString); >+ } catch (SAXException e) >+ { >+ WsdmToolingLog.logError(e.getMessage(), e); >+ } catch (IOException e) >+ { >+ WsdmToolingLog.logError(e.getMessage(), e); >+ } >+ if (document != null) >+ document.normalize(); >+ return document; >+ } >+ >+ public static Document createDocument(String xmlString) >+ throws SAXException, IOException >+ { >+ InputSource source = new InputSource(new StringReader(xmlString)); >+ return createDocument(source); >+ } >+ >+ public static Document createDocument(InputSource source) >+ throws SAXException, IOException >+ { >+ return createDocumentBuilder().parse(source); >+ } >+ >+ public static Document createDocument(InputStream stream) >+ throws SAXException, IOException >+ { >+ return createDocumentBuilder().parse(stream); >+ } >+ >+ private static DocumentBuilder createDocumentBuilder() >+ { >+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); >+ factory.setNamespaceAware(true); >+ factory.setIgnoringComments(true); >+ try >+ { >+ return factory.newDocumentBuilder(); >+ } catch (Throwable error) >+ { >+ WsdmToolingLog.logError(Messages.CANT_PARSE_XML_ERROR_, error); >+ } >+ return null; >+ } >+ >+ public static String documentToString(Document document) >+ { >+ XMLSerializer serializer = new XMLSerializer(); >+ serializer.setNamespaces(true); >+ >+ OutputFormat formatter = new OutputFormat(); >+ formatter.setOmitXMLDeclaration(false); >+ formatter.setIndenting(true); >+ serializer.setOutputFormat(formatter); >+ >+ StringWriter writer = new StringWriter(); >+ serializer.setOutputCharStream(writer); >+ >+ try >+ { >+ serializer.serialize(document); >+ } catch (Throwable error) >+ { >+ WsdmToolingLog.logError(Messages.CANT_SERIALIZE_DOCUMENT_ERROR_, >+ error); >+ } >+ return writer.toString(); >+ } >+ >+ /** >+ * Returns the instances of property of the given name. >+ */ >+ public static int getInstancesOfProperty(Capability model, String propName) >+ { >+ int counter = 0; >+ EList propList = model.getProperties(); >+ for (int i = 0; i < propList.size(); i++) >+ { >+ Property property = (Property) propList.get(i); >+ String name = XsdUtils.getName(property.getElement()); >+ if (name.equals(propName)) >+ counter++; >+ } >+ return counter; >+ } >+ >+ /** >+ * Returns the instances of operation of the given name. >+ */ >+ public static int getInstancesOfOperation(Capability model, String opName) >+ { >+ int counter = 0; >+ EList opList = model.getOperations(); >+ for (int i = 0; i < opList.size(); i++) >+ { >+ Operation op = (Operation) opList.get(i); >+ if (op.getName().equals(opName)) >+ counter++; >+ } >+ return counter; >+ } >+ >+ /** >+ * Returns the instances of parameter of the given name. >+ */ >+ public static int getInstancesOfParameter(Operation operation, >+ String paramName) >+ { >+ int counter = 0; >+ XSDElementDeclaration[] params = WsdlUtils >+ .getOperationParams(operation); >+ for (int i = 0; i < params.length; i++) >+ { >+ if (params[i].getName().equals(paramName)) >+ counter++; >+ } >+ return counter; >+ } >+ >+ /** >+ * >+ * Validate whether given string is valid identifier or not NOTE : Fix for >+ * defect [#47609] Validation needed on text fields in editors >+ */ >+ public static String validateJavaIdentifier(String name) >+ { >+ // A Java identifier begins with a JavaLetter, followed by 0..n >+ // JavaLetterOrDigit, >+ // but MUST NOT be a Java Keyword, true, false, or null >+ >+ if (name.length() == 0) >+ { >+ return Messages.EMPTY_NAME_ERROR_; >+ } >+ >+ if (!Character.isJavaIdentifierStart(name.charAt(0))) >+ { >+ return NLS.bind(Messages.INVALID_NAME_ERROR_, name); >+ } >+ >+ for (int i = 1; i < name.length(); i++) >+ { >+ if (!Character.isJavaIdentifierPart(name.charAt(i))) >+ { >+ return NLS.bind(Messages.INVALID_NAME_ERROR_, name); >+ } >+ } >+ >+ if (JAVA_KEYWORDS.contains(name)) >+ { >+ return NLS.bind(Messages.INVALID_NAME_JAVA_KEYWORD_ERROR_, name); >+ } >+ return null; >+ } >+ >+ /** >+ * Returns the property of the given name. >+ */ >+ public static Property getProperty(Capability capability, String namespace, >+ String propertyName) >+ { >+ List propList = capability.getProperties(); >+ for (int i = 0; i < propList.size(); i++) >+ { >+ Property property = (Property) propList.get(i); >+ XSDElementDeclaration propElement = property.getElement(); >+ String name = XsdUtils.getName(propElement); >+ if (propElement.getTargetNamespace().equals(namespace) >+ && name.equals(propertyName)) >+ return property; >+ } >+ return null; >+ } >+ >+ /** >+ * Returns the name of the property. >+ */ >+ public static String getName(Property property) >+ { >+ return XsdUtils.getName(property.getElement()); >+ } >+ >+ /** >+ * Returns the capability DescriptionNode. >+ */ >+ public static Text getDescriptionNode(Definition definition) >+ { > XSDSchema schema = WsdlUtils.getSchema(definition, definition > .getTargetNamespace()); >- if (schema != null) { >+ if (schema != null) >+ { > if (schema.getAnnotations() != null >- && schema.getAnnotations().size() != 0) { >+ && schema.getAnnotations().size() != 0) >+ { > XSDAnnotation annotation = (XSDAnnotation) schema > .getAnnotations().get(0); > List userInfo = annotation.getUserInformation(); >- if (userInfo != null && userInfo.size() != 0) { >+ if (userInfo != null && userInfo.size() != 0) >+ { > Element[] elements = getEmptySourceDocumentationElements(userInfo); >- for (int i = 0; i < elements.length; i++) { >- if (elements[i].getChildNodes().getLength() != 0) { >- if (elements[i].getChildNodes().item(0) instanceof Text) { >+ for (int i = 0; i < elements.length; i++) >+ { >+ if (elements[i].getChildNodes().getLength() != 0) >+ { >+ if (elements[i].getChildNodes().item(0) instanceof Text) >+ { > Text node = (Text) elements[i].getChildNodes() > .item(0); > return node; >@@ -508,100 +565,114 @@ > } > } > } >- return null; >- } >+ return null; >+ } >+ >+ private static Element[] getEmptySourceDocumentationElements(List elements) >+ { >+ List result = new ArrayList(); >+ for (int i = 0; i < elements.size(); i++) >+ { >+ Element documentation = (Element) elements.get(i); >+ if (documentation.getAttributes().getLength() == 0) >+ result.add(documentation); >+ } >+ return (Element[]) result.toArray(new Element[result.size()]); >+ } > >- private static Element[] getEmptySourceDocumentationElements(List elements) >- { >- List result = new ArrayList(); >- for (int i = 0; i < elements.size(); i++) >- { >- Element documentation = (Element) elements.get(i); >- if (documentation.getAttributes().getLength() == 0) >- result.add(documentation); >- } >- return (Element[]) result.toArray(new Element[result.size()]); >- } >- >- /** >- * Returns the Map of All capabilites available (Standarad+Workspace). >- * Key will be Capability URI and Value will be List of Capability WSDL Definition >- * which maps to same Capability URI. >- * @throws Exception >- */ >- public static Map getAllCapabilitiesMap() throws Exception{ >- if(standardCapabilityMap == null){ >- standardCapabilityMap = new HashMap(); >- // Get All ManagementCapabilities >- Definition[] caps = (Definition[]) MrtUtils.getManagementCapabilities().toArray(new Definition[0]); >- poplulateCapabilityMap(standardCapabilityMap, caps); >- // Get All ManagementRelatedCapabilities >- caps = (Definition[]) MrtUtils.getManagementRelatedCapabilities().toArray(new Definition[0]); >- poplulateCapabilityMap(standardCapabilityMap, caps); >- // Get All ResourcePropertyCapabilities >- caps = (Definition[]) MrtUtils.getResourcePropertyCapabilities().toArray(new Definition[0]); >- poplulateCapabilityMap(standardCapabilityMap, caps); >- // Get All ResourceLifetimeCapabilities >- caps = (Definition[]) MrtUtils.getResourceLifetimeCapabilities().toArray(new Definition[0]); >- poplulateCapabilityMap(standardCapabilityMap, caps); >- } >- Map allCapabilities = new HashMap(); >- allCapabilities.putAll(standardCapabilityMap); >- // Get All WorkspaceCapabilities >- Definition[] workspaceCapabilities = getAllWorkspaceCapabilities(); >- poplulateCapabilityMap(allCapabilities, workspaceCapabilities); >- return allCapabilities; >- } >- >- private static void poplulateCapabilityMap(Map map, Definition[] capabilities){ >- for(int i=0;i<capabilities.length;i++){ >+ /** >+ * Returns the Map of All capabilites available (Standarad+Workspace). Key >+ * will be Capability URI and Value will be List of Capability WSDL >+ * Definition which maps to same Capability URI. >+ * >+ * @throws Exception >+ */ >+ public static Map getAllCapabilitiesMap() throws Exception >+ { >+ if (standardCapabilityMap == null) >+ { >+ standardCapabilityMap = new HashMap(); >+ // Get All ManagementCapabilities >+ Definition[] caps = (Definition[]) MrtUtils >+ .getManagementCapabilities().toArray(new Definition[0]); >+ poplulateCapabilityMap(standardCapabilityMap, caps); >+ // Get All ManagementRelatedCapabilities >+ caps = (Definition[]) MrtUtils.getManagementRelatedCapabilities() >+ .toArray(new Definition[0]); >+ poplulateCapabilityMap(standardCapabilityMap, caps); >+ // Get All ResourcePropertyCapabilities >+ caps = (Definition[]) MrtUtils.getResourcePropertyCapabilities() >+ .toArray(new Definition[0]); >+ poplulateCapabilityMap(standardCapabilityMap, caps); >+ // Get All ResourceLifetimeCapabilities >+ caps = (Definition[]) MrtUtils.getResourceLifetimeCapabilities() >+ .toArray(new Definition[0]); >+ poplulateCapabilityMap(standardCapabilityMap, caps); >+ } >+ Map allCapabilities = new HashMap(); >+ allCapabilities.putAll(standardCapabilityMap); >+ // Get All WorkspaceCapabilities >+ Definition[] workspaceCapabilities = getAllWorkspaceCapabilities(); >+ poplulateCapabilityMap(allCapabilities, workspaceCapabilities); >+ return allCapabilities; >+ } >+ >+ private static void poplulateCapabilityMap(Map map, >+ Definition[] capabilities) >+ { >+ for (int i = 0; i < capabilities.length; i++) >+ { > String key = capabilities[i].getNamespace("capabilityURI"); >- if(key == null) >+ if (key == null) > key = capabilities[i].getTargetNamespace(); > Object value = map.get(key); >- if(value == null){ >+ if (value == null) >+ { > List list = new LinkedList(); > list.add(capabilities[i]); >- map.put(key, list); >+ map.put(key, list); > } >- else{ >+ else >+ { > List list = (List) value; > list.add(capabilities[i]); >- } >+ } > } >- } >- >- >- /** >- * Returns all the Workspace capabilities. >- */ >- public static Definition[] getAllWorkspaceCapabilities() throws Exception{ >- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); >- List allWSDLs = new LinkedList(); >- List wsdls = EclipseUtils.getResourcesOfExtension(root, "mcap"); >- for (int i=0;i<wsdls.size();i++) { >- IFile wsdlFile = (IFile)wsdls.get(i); >+ } >+ >+ /** >+ * Returns all the Workspace capabilities. >+ */ >+ public static Definition[] getAllWorkspaceCapabilities() throws Exception >+ { >+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); >+ List allWSDLs = new LinkedList(); >+ List wsdls = EclipseUtils.getResourcesOfExtension(root, "mcap"); >+ for (int i = 0; i < wsdls.size(); i++) >+ { >+ IFile wsdlFile = (IFile) wsdls.get(i); > Definition wsdlDef = WsdlUtils.getWSDLDefinition(wsdlFile); >- if(wsdlDef!=null) >+ if (wsdlDef != null) > allWSDLs.add(wsdlDef); > } >- return (Definition[]) allWSDLs.toArray(new Definition[allWSDLs.size()]); >- } >- >- /** >- * Returns true if given operation name conflicted with super java capability implementation classes. >- * Note : Fix for defect 167792 "Operations from abstract capability classes need to be identified" >- * http://bugs.eclipse.org/bugs/show_bug.cgi?id=167792 >- */ >- public static boolean isOperationNameConflicted(String operationName) >- { >- if(operationName == null) >- return false; >- for(int i=0;i<abstractCapabilityMethods.length;i++) >- { >- if(abstractCapabilityMethods[i].getName().equals(operationName)) >- return true; >- } >- return false; >- } >+ return (Definition[]) allWSDLs.toArray(new Definition[allWSDLs.size()]); >+ } >+ >+ /** >+ * Returns true if given operation name conflicted with super java >+ * capability implementation classes. Note : Fix for defect 167792 >+ * "Operations from abstract capability classes need to be identified" >+ * http://bugs.eclipse.org/bugs/show_bug.cgi?id=167792 >+ */ >+ public static boolean isOperationNameConflicted(String operationName) >+ { >+ if (operationName == null) >+ return false; >+ for (int i = 0; i < abstractCapabilityMethods.length; i++) >+ { >+ if (abstractCapabilityMethods[i].getName().equals(operationName)) >+ return true; >+ } >+ return false; >+ } > } >Index: src/org/eclipse/tptp/wsdm/tooling/util/internal/TopicSpace2MetaDataDescriptor.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/util/internal/TopicSpace2MetaDataDescriptor.java >diff -N src/org/eclipse/tptp/wsdm/tooling/util/internal/TopicSpace2MetaDataDescriptor.java >--- src/org/eclipse/tptp/wsdm/tooling/util/internal/TopicSpace2MetaDataDescriptor.java 9 Jan 2007 19:52:24 -0000 1.3 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,161 +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.util.internal; >- >-import java.util.ArrayList; >-import java.util.Iterator; >-import java.util.List; >- >-import org.eclipse.emf.common.util.EMap; >-import org.eclipse.tptp.wsdm.tooling.model.capabilities.Topic; >-import org.eclipse.tptp.wsdm.tooling.model.capabilities.TopicSpace; >- >-/** >- * Generate a topic expression for each topic available in capability.<br> >- * So if capability has topics defined as<br><br> >- * http://w3.ibm.com/capabilities/WAS (TopicNameSpace)<br> >- * |____RootTopic <br> >- * |______ChildTopic <br><br> >- * >- * Then it will generate the following topic expressions in RMD<br><br> >- * >- * xmlns:topics1="http://w3.ibm.com/capabilities/WAS/Topics"<br> >- * >- * < wsnt:TopicExpression > topics1:RootTopic < /wsnt:TopicExpression ><br> >- * < wsnt:TopicExpression > topics1:RootTopic/ChildTopic < /wsnt:TopicExpression ><br> >- * >- * @see #getTopicExpressions() >- * >- */ >- >-public class TopicSpace2MetaDataDescriptor >-{ >- >- private List _topicSpaces; >- >- private List _generatedTopicExpressions; >- >- private EMap _nsMap; >- >- /** >- * Creates the instance of this class. >- */ >- public TopicSpace2MetaDataDescriptor(EMap nsMap, List topicSpaces) >- { >- _topicSpaces = topicSpaces; >- _nsMap = nsMap; >- _generatedTopicExpressions = new ArrayList(); >- } >- >- /** >- * >- * @return Topic expression. >- */ >- public String[] getTopicExpressions() >- { >- for (int i = 0; i < _topicSpaces.size(); i++) >- { >- TopicSpace topicSpace = (TopicSpace) _topicSpaces.get(i); >- visitTopicSpace(topicSpace); >- } >- return (String[]) _generatedTopicExpressions.toArray(new String[0]); >- } >- >- private void visitTopicSpace(TopicSpace topicSpace) >- { >- String prefix = getPrefix(topicSpace.getNamespace()); >- for (int i = 0; i < topicSpace.getRootTopics().size(); i++) >- { >- visitRootTopic((Topic) topicSpace.getRootTopics().get(i), prefix); >- } >- } >- >- private void visitRootTopic(Topic rootTopic, String prefix) >- { >- String topicExpression = prepareExpression(prefix, rootTopic); >- if (!_generatedTopicExpressions.contains(topicExpression)) >- _generatedTopicExpressions.add(topicExpression); >- >- for (int i = 0; i < rootTopic.getChildren().size(); i++) >- { >- visitTopic((Topic) rootTopic.getChildren().get(i), prefix); >- } >- } >- >- private void visitTopic(Topic topic, String prefix) >- { >- String topicExpression = prepareExpression(prefix, topic); >- if (!_generatedTopicExpressions.contains(topicExpression)) >- _generatedTopicExpressions.add(topicExpression); >- >- for (int i = 0; i < topic.getChildren().size(); i++) >- { >- visitTopic((Topic) topic.getChildren().get(i), prefix); >- } >- } >- >- private String prepareExpression(String prefix, Topic topic) >- { >- StringBuffer buffer = new StringBuffer(); >- buffer.append(topic.getName()); >- while (topic.getParent() != null) >- { >- topic = topic.getParent(); >- buffer.insert(0, topic.getName() + "/"); >- } >- buffer.insert(0, prefix + ":"); >- return buffer.toString(); >- } >- >- private String getPrefix(String ns) >- { >- Iterator keyIt = _nsMap.keySet().iterator(); >- Iterator valueIt = _nsMap.values().iterator(); >- while (keyIt.hasNext()) >- { >- String prefix = (String) keyIt.next(); >- String namespace = (String) valueIt.next(); >- if (namespace.equals(ns)) >- return prefix; >- } >- >- String newPrefix = generateNewPrefix(); >- _nsMap.put(newPrefix, ns); >- return newPrefix; >- } >- >- private String generateNewPrefix() >- { >- int counter = 1; >- String newPrefix = "topics" + counter; >- while (isPrefixExists(newPrefix)) >- { >- counter++; >- newPrefix = "topics" + counter; >- } >- return newPrefix; >- } >- >- private boolean isPrefixExists(String prefix) >- { >- Iterator keyIt = _nsMap.keySet().iterator(); >- while (keyIt.hasNext()) >- { >- String pfx = (String) keyIt.next(); >- if (pfx.equals(prefix)) >- return true; >- } >- return false; >- } >- >-} >Index: src/org/eclipse/tptp/wsdm/tooling/util/internal/TopicUtils.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/util/internal/TopicUtils.java >diff -N src/org/eclipse/tptp/wsdm/tooling/util/internal/TopicUtils.java >--- src/org/eclipse/tptp/wsdm/tooling/util/internal/TopicUtils.java 9 Jan 2007 19:52:24 -0000 1.4 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,63 +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.util.internal; >- >-import org.eclipse.tptp.wsdm.tooling.model.capabilities.CapabilitiesFactory; >-import org.eclipse.tptp.wsdm.tooling.model.capabilities.Topic; >-import org.eclipse.tptp.wsdm.tooling.model.capabilities.TopicSpace; >- >-/** >- * >- * Utility class to deal with capability topics. >- * >- */ >- >-public class TopicUtils >-{ >- >- public static final String WS_TOPICS_PREFIX = "wsnt"; >- >- private static final String TOPICSPACE_ELEMENT = "TopicSpace"; >- >- private static final String TOPIC_ELEMENT = "Topic"; >- >- private static final String MESSAGE_PATTERN_ELEMENT = "MessagePattern"; >- >- private static final String NAME_ATTRIBUTE = "name"; >- >- private static final String TARGET_NAMESPACE_ATTRIBUTE = "targetNamespace"; >- >- private static final String MESSAGE_TYPES_ATTRIBUTE = "messageTypes"; >- >- private static final String FINAL_ATTRIBUTE = "final"; >- >- /** >- * Creates new capability topic. >- * >- * @return new capability topic. >- */ >- public static Topic createNewTopic() >- { >- return CapabilitiesFactory.eINSTANCE.createTopic(); >- } >- >- /** >- * Creates new capability topicspace. >- * >- * @return new capability topicspace. >- */ >- public static TopicSpace createNewTopicSpace() >- { >- return CapabilitiesFactory.eINSTANCE.createTopicSpace(); >- } >-} >Index: src/org/eclipse/tptp/wsdm/tooling/util/internal/Definition2Capability.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.validation/src/org/eclipse/tptp/wsdm/tooling/util/internal/Definition2Capability.java,v >retrieving revision 1.4 >diff -u -r1.4 Definition2Capability.java >--- src/org/eclipse/tptp/wsdm/tooling/util/internal/Definition2Capability.java 9 Jan 2007 19:52:24 -0000 1.4 >+++ src/org/eclipse/tptp/wsdm/tooling/util/internal/Definition2Capability.java 20 Jan 2007 13:34:35 -0000 >@@ -18,12 +18,11 @@ > > import javax.xml.namespace.QName; > >-import org.eclipse.core.resources.IFile; >-import org.eclipse.core.runtime.CoreException; > import org.eclipse.emf.common.util.URI; > import org.eclipse.tptp.wsdm.tooling.model.capabilities.CapabilitiesFactory; > import org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability; > import org.eclipse.tptp.wsdm.tooling.model.capabilities.Property; >+import org.eclipse.tptp.wsdm.tooling.model.capabilities.impl.MetadataDescriptor; > import org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.DocumentRoot; > import org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.PropertyType; > import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.internal.Messages; >@@ -31,7 +30,6 @@ > import org.eclipse.wst.wsdl.Operation; > import org.eclipse.wst.wsdl.PortType; > import org.eclipse.xsd.XSDElementDeclaration; >-import org.eclipse.xsd.XSDSchema; > import org.w3c.dom.Text; > > /** >@@ -39,324 +37,325 @@ > * > * There are 2 costructors provided to intialize this class.<br> > * >- * <b>public Definition2Capability(Definition wsdlDefinition, boolean loadProperties, >- * boolean loadRMD, boolean loadOperations,boolean loadTopics)</b> <br> >+ * <b>public Definition2Capability(Definition wsdlDefinition, boolean >+ * loadProperties, boolean loadRMD, boolean loadOperations,boolean loadTopics)</b> >+ * <br> > * > * Using this constructor one can load perticluar component of a capability.<br> > * >- * Anoter constructor available which will load all the component of a capability.<br> >+ * Anoter constructor available which will load all the component of a >+ * capability.<br> > * > * <b>public Definition2Capability(Definition wsdlDefinition)</b><br> > * >- * <b>getCapability()</b> method will trigger the conversion and will return the corresponding capability.<br> >- * >+ * <b>getCapability()</b> method will trigger the conversion and will return >+ * the corresponding capability.<br> >+ * > */ > > public class Definition2Capability > { > >- protected Capability _capability = null; >+ protected Capability _capability = null; > >- protected boolean _loadProperties; >+ protected boolean _loadProperties; > >- protected boolean _loadRMD; >+ protected boolean _loadRMD; > >- protected boolean _loadOperations; >+ protected boolean _loadOperations; > >- protected boolean _loadTopics; >- >- protected List _diagonistics = new LinkedList(); >- >- private Map _metaDataMap; >- >- protected Definition _wsdlDefinition; >- >- private XSDElementDeclaration _resourcePropertyElement; >- >- private PropertyMetaDataDescriptor _metaDataDescriptor; >- >- public static String RMD_FILE_NOT_EXISTS_MESSAGE = Messages.RMD_FILE_DOESNT_EXISTS_ERROR_; >- >- public static String INVALID_WSDL_MESSAGE = Messages.IMPROPER_WSDL_FILE_ERROR_; >- >- public static String WSDL_LOCATION_NOT_RESOLVE = Messages.UNRESOLVED_WSDL_LOCATION_ERROR_; >- >- public static String NO_RP_ATTRIBUTE_MESSAGE = Messages.NO_RP_ATTRIBUTE_WARN_; >- >- public static String NO_METADESCRIPTOR_LOCATION_MESSAGE = Messages.NO_METADESCRIPTOR_LOCATION_WARN_; >- >- public static String NO_METADESCRIPTOR_MESSAGE = Messages.NO_METADESCRIPTOR_WARN_; >- >- public static String NO_RP_ELEMENT_MESSAGE = Messages.NO_RP_ELEMENT_ERROR_; >- >- public Definition2Capability(Definition wsdlDefinition) >- { >- this(wsdlDefinition, true, true, true, true); >- } >- >- public Definition2Capability(Definition wsdlDefinition, >- boolean loadProperties, boolean loadRMD, boolean loadOperations, >- boolean loadTopics) >- { >- _wsdlDefinition = wsdlDefinition; >- _capability = null; >- _loadProperties = loadProperties; >- _loadRMD = loadRMD; >- _loadOperations = loadOperations; >- _loadTopics = loadTopics; >- } >- >- /** >- * Boolean parameter to load the properties of capability. >- * >- */ >- public void setLoadProperties(boolean load) >- { >- _loadProperties = load; >- } >- >- /** >- * Boolean parameter to load the metadata of capability. >- * >- */ >- public void setLoadRMD(boolean load) >- { >- _loadRMD = load; >- } >- >- /** >- * Boolean parameter to load the operations of capability. >- * >- */ >- public void setLoadOperations(boolean load) >- { >- _loadOperations = load; >- } >- >- /** >- * Boolean parameter to load the topics of capability. >- * >- */ >- public void setLoadTopics(boolean load) >- { >- _loadTopics = load; >- } >- >- /** >- * Returns the diagnostics list. >- */ >- public List getDiagonistics() >- { >- return _diagonistics; >- } >- >- /** >- * Returns the capability. >- */ >- public Capability getCapability() >- { >- startConversion(); >- return _capability; >- } >- >- /** >- * Returns the resource property element. >- */ >- public XSDElementDeclaration getResourcePropertyElement() >- { >- return _resourcePropertyElement; >- } >- >- /** >- * Returns the wsdl definition. >- */ >- public Definition getWSDLDefinition() >- { >- return _wsdlDefinition; >- } >- >- /** >- * Returns the PropertyMetaDataDescriptor. >- */ >- public PropertyMetaDataDescriptor getPropertyMetaDataDescriptor() >- { >- return _metaDataDescriptor; >- } >- >- private void startConversion() >- { >- if (!isValidCapability()) >- return; >- populateCapabilityInfo(); >- >- if (_metaDataMap != null) >- { >- >- String resourceProperties = (String) _metaDataMap >- .get(WsdlUtils.RESOURCE_PROPERTIES_ELEMENT_KEY); >- String metadataDescriptorLocation = (String) _metaDataMap >- .get(WsdlUtils.METADATA_DESCRIPTOR_LOCATION_KEY); >- String metadataDescriptorName = (String) _metaDataMap >- .get(WsdlUtils.METADATA_DESCRIPTOR_KEY); >- >- if (resourceProperties != null) >- { >- _resourcePropertyElement = WsdlUtils.getResourcePropertyElement( >- _wsdlDefinition, resourceProperties); >- if (_loadProperties) >- if (!populateCapabilityProperties()) >- return; >- } >+ protected boolean _loadTopics; >+ >+ protected List _diagonistics = new LinkedList(); >+ >+ private Map _metaDataMap; >+ >+ protected Definition _wsdlDefinition; >+ >+ private XSDElementDeclaration _resourcePropertyElement; >+ >+ public static String RMD_FILE_NOT_EXISTS_MESSAGE = Messages.RMD_FILE_DOESNT_EXISTS_ERROR_; >+ >+ public static String INVALID_WSDL_MESSAGE = Messages.IMPROPER_WSDL_FILE_ERROR_; >+ >+ public static String WSDL_LOCATION_NOT_RESOLVE = Messages.UNRESOLVED_WSDL_LOCATION_ERROR_; >+ >+ public static String NO_RP_ATTRIBUTE_MESSAGE = Messages.NO_RP_ATTRIBUTE_WARN_; >+ >+ public static String NO_METADESCRIPTOR_LOCATION_MESSAGE = Messages.NO_METADESCRIPTOR_LOCATION_WARN_; >+ >+ public static String NO_METADESCRIPTOR_MESSAGE = Messages.NO_METADESCRIPTOR_WARN_; >+ >+ public static String NO_RP_ELEMENT_MESSAGE = Messages.NO_RP_ELEMENT_ERROR_; >+ >+ public Definition2Capability(Definition wsdlDefinition) >+ { >+ this(wsdlDefinition, true, true, true, true); >+ } >+ >+ public Definition2Capability(Definition wsdlDefinition, >+ boolean loadProperties, boolean loadRMD, boolean loadOperations, >+ boolean loadTopics) >+ { >+ _wsdlDefinition = wsdlDefinition; >+ _capability = null; >+ _loadProperties = loadProperties; >+ _loadRMD = loadRMD; >+ _loadOperations = loadOperations; >+ _loadTopics = loadTopics; >+ } >+ >+ /** >+ * Boolean parameter to load the properties of capability. >+ * >+ */ >+ public void setLoadProperties(boolean load) >+ { >+ _loadProperties = load; >+ } >+ >+ /** >+ * Boolean parameter to load the metadata of capability. >+ * >+ */ >+ public void setLoadRMD(boolean load) >+ { >+ _loadRMD = load; >+ } >+ >+ /** >+ * Boolean parameter to load the operations of capability. >+ * >+ */ >+ public void setLoadOperations(boolean load) >+ { >+ _loadOperations = load; >+ } >+ >+ /** >+ * Boolean parameter to load the topics of capability. >+ * >+ */ >+ public void setLoadTopics(boolean load) >+ { >+ _loadTopics = load; >+ } >+ >+ /** >+ * Returns the diagnostics list. >+ */ >+ public List getDiagonistics() >+ { >+ return _diagonistics; >+ } >+ >+ /** >+ * Returns the capability. >+ */ >+ public Capability getCapability() >+ { >+ startConversion(); >+ return _capability; >+ } > >- if (metadataDescriptorLocation != null >- && metadataDescriptorName != null) >- { >- if (_loadRMD) >- if (!populateMetadata()) >+ /** >+ * Returns the resource property element. >+ */ >+ public XSDElementDeclaration getResourcePropertyElement() >+ { >+ return _resourcePropertyElement; >+ } >+ >+ /** >+ * Returns the wsdl definition. >+ */ >+ public Definition getWSDLDefinition() >+ { >+ return _wsdlDefinition; >+ } >+ >+ private void startConversion() >+ { >+ if (!isValidCapability()) > return; >+ populateCapabilityInfo(); >+ >+ if (_metaDataMap != null) >+ { >+ >+ String resourceProperties = (String) _metaDataMap >+ .get(WsdlUtils.RESOURCE_PROPERTIES_ELEMENT_KEY); >+ String metadataDescriptorLocation = (String) _metaDataMap >+ .get(WsdlUtils.METADATA_DESCRIPTOR_LOCATION_KEY); >+ String metadataDescriptorName = (String) _metaDataMap >+ .get(WsdlUtils.METADATA_DESCRIPTOR_KEY); >+ >+ if (resourceProperties != null) >+ { >+ _resourcePropertyElement = WsdlUtils >+ .getResourcePropertyElement(_wsdlDefinition, >+ resourceProperties); >+ if (_loadProperties) >+ if (!populateCapabilityProperties()) >+ return; >+ } >+ >+ if (metadataDescriptorLocation != null >+ && metadataDescriptorName != null) >+ { >+ if (_loadRMD) >+ if (!populateMetadata()) >+ return; >+ if (_loadTopics) >+ if (!populateCapabilityTopics()) >+ return; >+ } >+ } >+ >+ if (_loadOperations) >+ if (!populateCapabilityOperations()) >+ return; >+ > if (_loadTopics) >- if (!populateCapabilityTopics()) >- return; >- } >- } >+ if (!populateCapabilityTopics()) >+ return; > >- if (_loadOperations) >- if (!populateCapabilityOperations()) >- return; >- >- if(_loadTopics) >- if(!populateCapabilityTopics()) > return; >- >- return; >- } >- >- protected boolean isValidCapability() >- { >- if (_wsdlDefinition == null) >- { >- prepareErrorDiagnostics(INVALID_WSDL_MESSAGE); >- return false; >- } >- >- _metaDataMap = WsdlUtils.getMetadataFromPortType(_wsdlDefinition); >- >- return true; >- } >- >- protected void prepareErrorDiagnostics(String message) >- { >- WsdmToolingLog.logWarning(message); >- _diagonistics.add(message); >- _capability = null; >- } >- >- private void populateCapabilityInfo() >- { >- _capability = CapabilitiesFactory.eINSTANCE.createCapability(); >- QName qname = _wsdlDefinition.getQName(); >- String localPart = qname.getLocalPart(); >- String ns = _wsdlDefinition.getTargetNamespace(); >- String prefix = _wsdlDefinition.getPrefix(ns); >- Text node = CapUtils.getDescriptionNode(_wsdlDefinition); >- String description = ""; >- if (node != null) >- description = node.getData(); >- _capability.setNamespace(ns); >- _capability.setPrefix(prefix); >- _capability.setName(localPart); >- _capability.setDescription(description); >- } >- >- private boolean populateCapabilityProperties() >- { >- XSDElementDeclaration[] elements = CapUtils.getResolvedProperties( >- _wsdlDefinition, _resourcePropertyElement); >- _capability.getProperties().clear(); >- for (int i = 0; i < elements.length; i++) >- { >- Property property = CapabilitiesFactory.eINSTANCE.createProperty(); >- property.setElement(elements[i]); >- _capability.getProperties().add(property); >- } >- return true; >- } >- >- private boolean populateMetadata() >- { >- String metadataDescriptorLocation = (String) _metaDataMap >- .get(WsdlUtils.METADATA_DESCRIPTOR_LOCATION_KEY); >- String metadataDescriptorName = (String) _metaDataMap >- .get(WsdlUtils.METADATA_DESCRIPTOR_KEY); >- >- String wsdlPath = WsdlUtils.getWSDLFileLocation(_wsdlDefinition); >- if (wsdlPath == null) >- { >- prepareErrorDiagnostics(WSDL_LOCATION_NOT_RESOLVE); >- return false; >- } >- String wsdlContainer = wsdlPath.substring(0, wsdlPath.lastIndexOf("/")); >- String rmdFileLocation = wsdlContainer + "/" >- + metadataDescriptorLocation; >- URI rmdURI = URI.createURI(rmdFileLocation); >- DocumentRoot root = null; >- try { >- root = RmdUtils.getDocumentRoot(rmdURI); >- } catch (Exception e) { >- // Workaround for relationship rmd, because that rmd have property defined as >- // tns:Relationship/Name, and emf fails to load such kind of properties >- // We get the exception as >- // org.eclipse.emf.ecore.xmi.IllegalValueException: Value 'tns:Relationship/name' is not legal. >- // and we can't load the rmd for it >- if(e.getCause() instanceof org.eclipse.emf.ecore.xmi.IllegalValueException) >- return true; >- WsdmToolingLog.logError(Messages.FAILED_TO_LOAD_RMD_ERROR_, e); >- } >- if(root == null) >- prepareErrorDiagnostics(RMD_FILE_NOT_EXISTS_MESSAGE); >- >- _metaDataDescriptor = new PropertyMetaDataDescriptor(root, _capability, >- metadataDescriptorName); >- >- List props = _capability.getProperties(); >- if(props == null || props.size() == 0) >- return true; >- >- for(int i=0;i<props.size();i++) >- { >- Property property = (Property) props.get(i); >- XSDElementDeclaration element = property.getElement(); >- String name = XsdUtils.getName(element); >- PropertyType propertyMetadata = _metaDataDescriptor.getPropertyMetadata(name, element.getTargetNamespace()); >- if(propertyMetadata!=null) >- property.setMetaData(propertyMetadata); >- } >- return true; >- } >- >- private boolean populateCapabilityOperations() >- { >- PortType pt = WsdlUtils.getPortType(_wsdlDefinition); >- if(pt == null) >- return true; >- Operation[] operations = WsdlUtils.getWSDLOperation(_wsdlDefinition); >- _capability.getOperations().clear(); >- for (int i = 0; i < operations.length; i++) >- { >- _capability.getOperations().add(operations[i]); >- } >- return true; >- } >- >- private boolean populateCapabilityTopics() >- { >- if(_metaDataDescriptor == null) >- return true; >- if(_metaDataDescriptor.getDocumentRoot() == null || _metaDataDescriptor.getMetadataDescriptorType() == null) >- return true; >- List topicSpaces = _metaDataDescriptor.getTopicSpaces(); >- _capability.getTopicSpaces().clear(); >- _capability.getTopicSpaces().addAll(topicSpaces); >- return true; >- } >+ } >+ >+ protected boolean isValidCapability() >+ { >+ if (_wsdlDefinition == null) >+ { >+ prepareErrorDiagnostics(INVALID_WSDL_MESSAGE); >+ return false; >+ } >+ >+ _metaDataMap = WsdlUtils.getMetadataFromPortType(_wsdlDefinition); >+ >+ return true; >+ } >+ >+ protected void prepareErrorDiagnostics(String message) >+ { >+ WsdmToolingLog.logWarning(message); >+ _diagonistics.add(message); >+ _capability = null; >+ } >+ >+ private void populateCapabilityInfo() >+ { >+ _capability = CapabilitiesFactory.eINSTANCE.createCapability(); >+ QName qname = _wsdlDefinition.getQName(); >+ String localPart = qname.getLocalPart(); >+ String ns = _wsdlDefinition.getTargetNamespace(); >+ String prefix = _wsdlDefinition.getPrefix(ns); >+ Text node = CapUtils.getDescriptionNode(_wsdlDefinition); >+ String description = ""; >+ if (node != null) >+ description = node.getData(); >+ _capability.setNamespace(ns); >+ _capability.setPrefix(prefix); >+ _capability.setName(localPart); >+ _capability.setDescription(description); >+ _capability.setDefinition(_wsdlDefinition); >+ } >+ >+ private boolean populateCapabilityProperties() >+ { >+ XSDElementDeclaration[] elements = CapUtils.getResolvedProperties( >+ _wsdlDefinition, _resourcePropertyElement); >+ _capability.getProperties().clear(); >+ for (int i = 0; i < elements.length; i++) >+ { >+ Property property = CapabilitiesFactory.eINSTANCE.createProperty(); >+ property.setElement(elements[i]); >+ _capability.getProperties().add(property); >+ } >+ return true; >+ } >+ >+ private boolean populateMetadata() >+ { >+ String metadataDescriptorLocation = (String) _metaDataMap >+ .get(WsdlUtils.METADATA_DESCRIPTOR_LOCATION_KEY); >+ String metadataDescriptorName = (String) _metaDataMap >+ .get(WsdlUtils.METADATA_DESCRIPTOR_KEY); >+ >+ String wsdlPath = WsdlUtils.getWSDLFileLocation(_wsdlDefinition); >+ if (wsdlPath == null) >+ { >+ prepareErrorDiagnostics(WSDL_LOCATION_NOT_RESOLVE); >+ return false; >+ } >+ String wsdlContainer = wsdlPath.substring(0, wsdlPath.lastIndexOf("/")); >+ String rmdFileLocation = wsdlContainer + "/" >+ + metadataDescriptorLocation; >+ URI rmdURI = URI.createURI(rmdFileLocation); >+ DocumentRoot root = null; >+ try >+ { >+ root = RmdUtils.getDocumentRoot(rmdURI); >+ } catch (Exception e) >+ { >+ // Workaround for relationship rmd, because that rmd have property >+ // defined as >+ // tns:Relationship/Name, and emf fails to load such kind of >+ // properties >+ // We get the exception as >+ // org.eclipse.emf.ecore.xmi.IllegalValueException: Value >+ // 'tns:Relationship/name' is not legal. >+ // and we can't load the rmd for it >+ if (e.getCause() instanceof org.eclipse.emf.ecore.xmi.IllegalValueException) >+ return true; >+ WsdmToolingLog.logError(Messages.FAILED_TO_LOAD_RMD_ERROR_, e); >+ } >+ if (root == null) >+ prepareErrorDiagnostics(RMD_FILE_NOT_EXISTS_MESSAGE); >+ >+ MetadataDescriptor _metaDataDescriptor = new MetadataDescriptor( >+ _capability, root, metadataDescriptorName); >+ >+ List props = _capability.getProperties(); >+ if (props == null || props.size() == 0) >+ return true; >+ >+ for (int i = 0; i < props.size(); i++) >+ { >+ Property property = (Property) props.get(i); >+ XSDElementDeclaration element = property.getElement(); >+ String name = XsdUtils.getName(element); >+ PropertyType propertyMetadata = _metaDataDescriptor >+ .getPropertyMetadata(name, element.getTargetNamespace()); >+ if (propertyMetadata != null) >+ property.setMetaData(propertyMetadata); >+ } >+ return true; >+ } >+ >+ private boolean populateCapabilityOperations() >+ { >+ PortType pt = WsdlUtils.getPortType(_wsdlDefinition); >+ if (pt == null) >+ return true; >+ Operation[] operations = WsdlUtils.getWSDLOperation(_wsdlDefinition); >+ _capability.getOperations().clear(); >+ for (int i = 0; i < operations.length; i++) >+ { >+ _capability.getOperations().add(operations[i]); >+ } >+ return true; >+ } >+ >+ private boolean populateCapabilityTopics() >+ { >+ MetadataDescriptor _metaDataDescriptor = _capability.getMetadata(); >+ if (_metaDataDescriptor == null) >+ return true; >+ if (_metaDataDescriptor.getDocumentRoot() == null >+ || _metaDataDescriptor.getMetadataDescriptorType() == null) >+ return true; >+ _metaDataDescriptor.loadTopicSpaces(); >+ return true; >+ } > } >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.validation/META-INF/MANIFEST.MF,v >retrieving revision 1.7 >diff -u -r1.7 MANIFEST.MF >--- META-INF/MANIFEST.MF 2 Jan 2007 13:33:00 -0000 1.7 >+++ META-INF/MANIFEST.MF 20 Jan 2007 13:34:34 -0000 >@@ -15,8 +15,8 @@ > org.eclipse.tptp.wsdm.tooling.model, > org.apache.muse.api;visibility:=reexport, > org.apache.muse.core, >- org.apache.muse.utils;visibility:=reexport, >- org.apache.muse.tools >+ org.apache.muse.tools, >+ org.apache.xerces;visibility:=reexport > Eclipse-LazyStart: true > Export-Package: org.eclipse.tptp.wsdm.tooling.nls.messages.capability.internal, > org.eclipse.tptp.wsdm.tooling.nls.messages.capability.operation.internal, >@@ -38,4 +38,3 @@ > org.eclipse.tptp.wsdm.tooling.validation.wizard.internal > Bundle-ClassPath: runtime/validation.jar > Bundle-Vendor: %plugin.provider >-Import-Package: org.apache.xml.serialize >Index: src/org/eclipse/tptp/wsdm/tooling/validation/capability/internal/CapabilityWSDLValidator.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.wsdm.tooling.validation/src/org/eclipse/tptp/wsdm/tooling/validation/capability/internal/CapabilityWSDLValidator.java,v >retrieving revision 1.9 >diff -u -r1.9 CapabilityWSDLValidator.java >--- src/org/eclipse/tptp/wsdm/tooling/validation/capability/internal/CapabilityWSDLValidator.java 9 Jan 2007 19:52:24 -0000 1.9 >+++ src/org/eclipse/tptp/wsdm/tooling/validation/capability/internal/CapabilityWSDLValidator.java 20 Jan 2007 13:34:37 -0000 >@@ -20,7 +20,6 @@ > import javax.wsdl.factory.WSDLFactory; > import javax.wsdl.xml.WSDLReader; > >-import org.apache.muse.util.xml.XmlUtils; > import org.eclipse.core.runtime.CoreException; > import org.eclipse.osgi.util.NLS; > import org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability; >@@ -63,419 +62,459 @@ > public class CapabilityWSDLValidator > { > >- private IValidationReport _consolidatedReport = new EmptyValidationReport(); >+ private IValidationReport _consolidatedReport = new EmptyValidationReport(); > >- private static final String INVALID_CAPABILITY_NAME_MESSAGE = Messages.INVALID_CAPABILITY_NAME_MESSAGE; >+ private static final String INVALID_CAPABILITY_NAME_MESSAGE = Messages.INVALID_CAPABILITY_NAME_MESSAGE; > >- private static final String INVALID_CAPABILITY_NAMESPACE_MESSAGE = Messages.INVALID_CAPABILITY_NAMESPACE_MESSAGE; >+ private static final String INVALID_CAPABILITY_NAMESPACE_MESSAGE = Messages.INVALID_CAPABILITY_NAMESPACE_MESSAGE; > >- private static final String NO_PORT_TYPE_MESSAGE = Messages.NO_PORT_TYPE_MESSAGE; >+ private static final String NO_PORT_TYPE_MESSAGE = Messages.NO_PORT_TYPE_MESSAGE; > >- private static final String NO_RP_ELEMENT_MESSAGE = Messages.NO_RP_ELEMENT_MESSAGE; >- >- private static final String NO_METADESCRIPTOR_LOCATION_ELEMENT_MESSAGE = Messages.NO_METADESCRIPTOR_LOCATION_ELEMENT_MESSAGE; >- >- private static final String NO_METADESCRIPTOR_ELEMENT_MESSAGE = Messages.NO_METADESCRIPTOR_ELEMENT_MESSAGE; >- >- private static final String RP_ELEMENT_NOT_FOUND_MESSAGE = Messages.RP_ELEMENT_NOT_FOUND_MESSAGE; >- >- private static final String CONFLICTED_OPERATION = org.eclipse.tptp.wsdm.tooling.nls.messages.capability.operation.internal.Messages.CONFLICTED_OPERATION_WARN_; >- >- private static final String DUPLICATE_OPERATION_MESSAGE = "Duplicate operation"; >- >- private static final String DUPLICATE_PARAM_MESSAGE = "Duplicate parameter"; >- >- private static final String INVALID_OPERATION_NAME_MESSAGE = "Invalid operation name"; >- >- private static final String INVALID_PARAM_NAME_MESSAGE = "Invalid parameter name"; >- >- /** >- * Creates object of this class. >- */ >- public CapabilityWSDLValidator() >- { >- } >- >- /** >- * Perform WSDL validation >- */ >- public IValidationReport validate(Definition definition) >- { >- // Do Validation >- performWSDLValidation(definition); >- performExtraValidation(definition); >- >- return _consolidatedReport; >- } >- >- private void performWSDLValidation(Definition definition) >- { >- ByteArrayOutputStream baos; >- try >- { >- baos = WsdlUtils.saveWSDLDefinition(definition, >- definition.eResource().getURI().toString(), null); >- } catch (IOException e1) >- { >- return; >- } >- String docString = new String(baos.toByteArray()); >- Document document = null; >- >- try >- { >- document = XmlUtils.createDocument(docString); >- } catch (IOException exception) >- { >- IValidationMessage message = ValidationUtils >- .createNewErrorMessage(exception.getMessage()); >- _consolidatedReport.addValidationMessage(message); >- return; >- } catch (SAXException exception) >- { >- IValidationMessage message = ValidationUtils >- .createNewErrorMessage(exception.getMessage()); >- _consolidatedReport.addValidationMessage(message); >- return; >- } >- >- WSDLFactory factory = new WSDLFactoryImpl(); >- WSDLReader reader = factory.newWSDLReader(); >- try >- { >- String baseURI; >- try >- { >- baseURI = WsdlUtils.getLocalSystemWSDLLocation(definition); >- } catch (CoreException e) >- { >- return; >- } >- reader.readWSDL(baseURI, document); >- } >- catch (WSDLException exception) >- { >- IValidationMessage message = ValidationUtils >- .createNewErrorMessage(exception.getMessage()); >- _consolidatedReport.addValidationMessage(message); >- } >- } >- >- private void performExtraValidation(Definition definition) >- { >- String name = definition.getQName().getLocalPart(); >- String namespace = definition.getTargetNamespace(); >- >- // Validate capability name >- if (name == null || name.equals("")) >- { >- IValidationMessage message = ValidationUtils >- .createNewErrorMessage(INVALID_CAPABILITY_NAME_MESSAGE); >- _consolidatedReport.addValidationMessage(message); >- } >- >- // Validate capability namespace >- if (!Validation.isNamespace(namespace)) >- { >- IValidationMessage message = ValidationUtils >- .createNewErrorMessage(INVALID_CAPABILITY_NAMESPACE_MESSAGE); >- _consolidatedReport.addValidationMessage(message); >- } >- >- // Validate Duplicate capability >- // NOTE : Fix for Bug 167600 "No validation, When Creating Duplicate Capability" >- // http://bugs.eclipse.org/bugs/show_bug.cgi?id=167600 >- try { >- Map capabilitiesMap = CapUtils.getAllCapabilitiesMap(); >- Object value = capabilitiesMap.get(namespace); >- if(value!=null){ >- List list = (List) value; >- if(list.size()>1){ >+ private static final String NO_RP_ELEMENT_MESSAGE = Messages.NO_RP_ELEMENT_MESSAGE; >+ >+ private static final String NO_METADESCRIPTOR_LOCATION_ELEMENT_MESSAGE = Messages.NO_METADESCRIPTOR_LOCATION_ELEMENT_MESSAGE; >+ >+ private static final String NO_METADESCRIPTOR_ELEMENT_MESSAGE = Messages.NO_METADESCRIPTOR_ELEMENT_MESSAGE; >+ >+ private static final String RP_ELEMENT_NOT_FOUND_MESSAGE = Messages.RP_ELEMENT_NOT_FOUND_MESSAGE; >+ >+ private static final String CONFLICTED_OPERATION = org.eclipse.tptp.wsdm.tooling.nls.messages.capability.operation.internal.Messages.CONFLICTED_OPERATION_WARN_; >+ >+ private static final String DUPLICATE_OPERATION_MESSAGE = "Duplicate operation"; >+ >+ private static final String DUPLICATE_PARAM_MESSAGE = "Duplicate parameter"; >+ >+ private static final String INVALID_OPERATION_NAME_MESSAGE = "Invalid operation name"; >+ >+ private static final String INVALID_PARAM_NAME_MESSAGE = "Invalid parameter name"; >+ >+ /** >+ * Creates object of this class. >+ */ >+ public CapabilityWSDLValidator() >+ { >+ } >+ >+ /** >+ * Perform WSDL validation >+ */ >+ public IValidationReport validate(Definition definition) >+ { >+ // Do Validation >+ performWSDLValidation(definition); >+ performExtraValidation(definition); >+ >+ return _consolidatedReport; >+ } >+ >+ private void performWSDLValidation(Definition definition) >+ { >+ ByteArrayOutputStream baos; >+ try >+ { >+ baos = WsdlUtils.saveWSDLDefinition(definition, definition >+ .eResource().getURI().toString(), null); >+ } catch (IOException e1) >+ { >+ return; >+ } >+ String docString = new String(baos.toByteArray()); >+ Document document = null; >+ >+ try >+ { >+ document = CapUtils.createDocument(docString); >+ } catch (IOException exception) >+ { >+ IValidationMessage message = ValidationUtils >+ .createNewErrorMessage(exception.getMessage()); >+ _consolidatedReport.addValidationMessage(message); >+ return; >+ } catch (SAXException exception) >+ { >+ IValidationMessage message = ValidationUtils >+ .createNewErrorMessage(exception.getMessage()); >+ _consolidatedReport.addValidationMessage(message); >+ return; >+ } >+ >+ WSDLFactory factory = new WSDLFactoryImpl(); >+ WSDLReader reader = factory.newWSDLReader(); >+ try >+ { >+ String baseURI; >+ try >+ { >+ baseURI = WsdlUtils.getLocalSystemWSDLLocation(definition); >+ } catch (CoreException e) >+ { >+ return; >+ } >+ reader.readWSDL(baseURI, document); >+ } catch (WSDLException exception) >+ { >+ IValidationMessage message = ValidationUtils >+ .createNewErrorMessage(exception.getMessage()); >+ _consolidatedReport.addValidationMessage(message); >+ } >+ } >+ >+ private void performExtraValidation(Definition definition) >+ { >+ String name = definition.getQName().getLocalPart(); >+ String namespace = definition.getTargetNamespace(); >+ >+ // Validate capability name >+ if (name == null || name.equals("")) >+ { >+ IValidationMessage message = ValidationUtils >+ .createNewErrorMessage(INVALID_CAPABILITY_NAME_MESSAGE); >+ _consolidatedReport.addValidationMessage(message); >+ } >+ >+ // Validate capability namespace >+ if (!Validation.isNamespace(namespace)) >+ { >+ IValidationMessage message = ValidationUtils >+ .createNewErrorMessage(INVALID_CAPABILITY_NAMESPACE_MESSAGE); >+ _consolidatedReport.addValidationMessage(message); >+ } >+ >+ // Validate Duplicate capability >+ // NOTE : Fix for Bug 167600 "No validation, When Creating Duplicate >+ // Capability" >+ // http://bugs.eclipse.org/bugs/show_bug.cgi?id=167600 >+ try >+ { >+ Map capabilitiesMap = CapUtils.getAllCapabilitiesMap(); >+ Object value = capabilitiesMap.get(namespace); >+ if (value != null) >+ { >+ List list = (List) value; >+ if (list.size() > 1) >+ { >+ IValidationMessage message = ValidationUtils >+ .createNewErrorMessage(Messages.bind( >+ Messages.DUPLICATE_CAPABILITY, name)); >+ _consolidatedReport.addValidationMessage(message); >+ } >+ } >+ } catch (Exception e) >+ { >+ IValidationMessage message = ValidationUtils >+ .createNewErrorMessage(e.getMessage()); >+ _consolidatedReport.addValidationMessage(message); >+ return; >+ } >+ >+ // Validate capability port type >+ PortType pt = WsdlUtils.getPortType(definition); >+ if (pt == null) >+ { >+ IValidationMessage message = ValidationUtils >+ .createNewErrorMessage(NO_PORT_TYPE_MESSAGE); >+ _consolidatedReport.addValidationMessage(message); >+ return; >+ } >+ >+ Map map = WsdlUtils.getMetadataFromPortType(definition); >+ >+ // Check for Resource property element >+ String resourceProperties = (String) map >+ .get(WsdlUtils.RESOURCE_PROPERTIES_ELEMENT_KEY); >+ if (resourceProperties == null || resourceProperties.equals("")) >+ { >+ IValidationMessage message = ValidationUtils >+ .createNewWarningMessage(NO_RP_ELEMENT_MESSAGE); >+ _consolidatedReport.addValidationMessage(message); >+ } >+ >+ // Check for Metadescriptor element >+ String metadataDescriptorLocation = (String) map >+ .get(WsdlUtils.METADATA_DESCRIPTOR_LOCATION_KEY); >+ if (metadataDescriptorLocation == null >+ || metadataDescriptorLocation.equals("")) >+ { >+ IValidationMessage message = ValidationUtils >+ .createNewWarningMessage(NO_METADESCRIPTOR_LOCATION_ELEMENT_MESSAGE); >+ _consolidatedReport.addValidationMessage(message); >+ } >+ >+ String metadataDescriptor = (String) map >+ .get(WsdlUtils.METADATA_DESCRIPTOR_KEY); >+ if (metadataDescriptor == null || metadataDescriptor.equals("")) >+ { >+ IValidationMessage message = ValidationUtils >+ .createNewWarningMessage(NO_METADESCRIPTOR_ELEMENT_MESSAGE); >+ _consolidatedReport.addValidationMessage(message); >+ } >+ >+ if (resourceProperties != null) >+ { >+ XSDElementDeclaration rpElement = WsdlUtils >+ .getResourcePropertyElement(definition, resourceProperties); >+ if (rpElement == null) >+ { > IValidationMessage message = ValidationUtils >- .createNewErrorMessage(Messages.bind(Messages.DUPLICATE_CAPABILITY, name)); >- _consolidatedReport.addValidationMessage(message); >+ .createNewErrorMessage(RP_ELEMENT_NOT_FOUND_MESSAGE); >+ _consolidatedReport.addValidationMessage(message); >+ } >+ else >+ { >+ performRPElementValidation(definition, rpElement); > } > } >- } catch (Exception e) { >- IValidationMessage message = ValidationUtils >- .createNewErrorMessage(e.getMessage()); >- _consolidatedReport.addValidationMessage(message); >- return; >- } >- >- // Validate capability port type >- PortType pt = WsdlUtils.getPortType(definition); >- if (pt == null) >- { >- IValidationMessage message = ValidationUtils >- .createNewErrorMessage(NO_PORT_TYPE_MESSAGE); >- _consolidatedReport.addValidationMessage(message); >- return; >- } >- >- Map map = WsdlUtils.getMetadataFromPortType(definition); >- >- // Check for Resource property element >- String resourceProperties = (String) map >- .get(WsdlUtils.RESOURCE_PROPERTIES_ELEMENT_KEY); >- if (resourceProperties == null || resourceProperties.equals("")) >- { >- IValidationMessage message = ValidationUtils >- .createNewWarningMessage(NO_RP_ELEMENT_MESSAGE); >- _consolidatedReport.addValidationMessage(message); >- } >- >- // Check for Metadescriptor element >- String metadataDescriptorLocation = (String) map >- .get(WsdlUtils.METADATA_DESCRIPTOR_LOCATION_KEY); >- if (metadataDescriptorLocation == null >- || metadataDescriptorLocation.equals("")) >- { >- IValidationMessage message = ValidationUtils >- .createNewWarningMessage(NO_METADESCRIPTOR_LOCATION_ELEMENT_MESSAGE); >- _consolidatedReport.addValidationMessage(message); >- } >- >- String metadataDescriptor = (String) map >- .get(WsdlUtils.METADATA_DESCRIPTOR_KEY); >- if (metadataDescriptor == null || metadataDescriptor.equals("")) >- { >- IValidationMessage message = ValidationUtils >- .createNewWarningMessage(NO_METADESCRIPTOR_ELEMENT_MESSAGE); >- _consolidatedReport.addValidationMessage(message); >- } >- >- if (resourceProperties != null) >- { >- XSDElementDeclaration rpElement = WsdlUtils >- .getResourcePropertyElement(definition, resourceProperties); >- if (rpElement == null) >- { >- IValidationMessage message = ValidationUtils >- .createNewErrorMessage(RP_ELEMENT_NOT_FOUND_MESSAGE); >- _consolidatedReport.addValidationMessage(message); >- } >- else >- { >- performRPElementValidation(definition, rpElement); >- } >- } >- // TODO Check for RMD exists and Descriptor exists >- // TODO Check for All in same namespace >- >- performOperationsValidation(definition); >- >- performWsdlMessagesValidation(definition); >- >- performBindingValidation(definition); >- } >- >- private void performOperationsValidation(Definition definition) >- { >- Definition2Capability def2Capability = new Definition2Capability( >- definition, false, false, true, false); >- Capability capability = def2Capability.getCapability(); >- List operations = capability.getOperations(); >- for (int i = 0; i < operations.size(); i++) >- { >- Operation operation = (Operation) operations.get(i); >- validateResolvedOperation(operation); >- String msg = CapUtils.validateJavaIdentifier(operation.getName()); >- if (msg != null) >- { >- IValidationMessage message = ValidationUtils >- .createNewErrorMessage(msg); >- _consolidatedReport.addValidationMessage(message); >- } >- if(CapUtils.isOperationNameConflicted(operation.getName())) >- { >- msg = org.eclipse.tptp.wsdm.tooling.nls.messages.capability.operation.internal.Messages.bind(CONFLICTED_OPERATION, operation.getName()); >- IValidationMessage message = ValidationUtils >- .createNewErrorMessage(msg); >- _consolidatedReport.addValidationMessage(message); >- } >- } >- // TODO Check for duplicate param name >- // TODO Check for invalid param name >- } >- >- private void validateResolvedOperation(Operation operation) >- { >- IValidationMessage unresolvedOperationMessage = ValidationUtils >- .createNewErrorMessage(Messages.bind(Messages.UNRESOLVED_OPERATION_MESSAGE, operation.getName())); >- if(operation.getEInput() != null) >- { >- if(operation.getEInput().getEMessage() == null) >- _consolidatedReport.addValidationMessage(unresolvedOperationMessage); >- >- } >- else >- _consolidatedReport.addValidationMessage(unresolvedOperationMessage); >- >- if(operation.getEOutput() != null) >- { >- if(operation.getEOutput().getEMessage() == null) >- _consolidatedReport.addValidationMessage(unresolvedOperationMessage); >- } >- else >- _consolidatedReport.addValidationMessage(unresolvedOperationMessage); >- } >- >- private void performRPElementValidation(Definition definition, >- XSDElementDeclaration resourcePropertyElement) >- { >- if (resourcePropertyElement.getAnonymousTypeDefinition() == null) >- return; >- XSDComplexTypeDefinition typeDef = (XSDComplexTypeDefinition) resourcePropertyElement >- .getAnonymousTypeDefinition(); >- XSDModelGroup modelGroup = XsdUtils.getXSDModelGroup(typeDef); >- XSDElementDeclaration[] elementRefs = XsdUtils >- .getElementDeclarations(modelGroup); >- for (int i = 0; i < elementRefs.length; i++) >- { >- if (XsdUtils.isReferencedElement(elementRefs[i])) >- { >- WsdlElementResolver resolver = new WsdlElementResolver( >- definition, resourcePropertyElement, elementRefs[i]); >- XSDElementDeclaration resolvedElement = resolver.resolve(); >- if (resolvedElement == null) >- { >- String unresolvedElementName = elementRefs[i].getResolvedElementDeclaration().getName(); >- IValidationMessage message = ValidationUtils >- .createNewErrorMessage(NLS.bind(Messages.UNRESOLVED_ELEMENT_MESSAGE,unresolvedElementName)); >- _consolidatedReport.addValidationMessage(message); >- } >- } >- } >- } >- >- private void performWsdlMessagesValidation(Definition definition){ >- if(definition == null) >- return; >- List messages = definition.getEMessages(); >- if(messages!=null) >- { >- for(int i=0;i<messages.size();i++) >- { >- Message message = (Message) messages.get(i); >- if(message.getEParts() == null || message.getEParts().size() == 0) >- { >- IValidationMessage valMessage = ValidationUtils.createNewErrorMessage(Messages.bind(Messages.WSDL_MESSAGE_ZERO_PART_MESSAGE, message.getQName().getLocalPart())); >- _consolidatedReport.addValidationMessage(valMessage); >- continue; >- } >- >- if(message.getEParts().size()>1) >- { >- IValidationMessage valMessage = ValidationUtils.createNewErrorMessage(Messages.bind(Messages.WSDL_MESSAGE_MORE_THAN_ONE_PART_MESSAGE, message.getQName().getLocalPart())); >- _consolidatedReport.addValidationMessage(valMessage); >- } >- } >- } >- List imports = definition.getEImports(); >- if(imports!=null) >- { >- for(int i=0;i<imports.size();i++) >- { >- Import theImport = (Import) imports.get(i); >- if(theImport.getLocationURI().endsWith("wsdl")) >- performWsdlMessagesValidation(theImport.getEDefinition()); >- } >- } >- } >- >- private void performBindingValidation(Definition definition){ >- if(definition == null) >- return; >- List bindings = definition.getEBindings(); >- if(bindings == null) >- return; >- for(int i=0;i<bindings.size();i++) >- { >- Binding binding = (Binding) bindings.get(i); >- validateBinding(binding); >- } >- List imports = definition.getEImports(); >- if(imports!=null) >- { >- for(int i=0;i<imports.size();i++) >- { >- Import theImport = (Import) imports.get(i); >- if(theImport.getLocationURI().endsWith("wsdl")) >- performBindingValidation(theImport.getEDefinition()); >- } >- } >- } >- >- private void validateBinding(Binding binding){ >- boolean isDocumentStyle = false; >- List extnElems = binding.getEExtensibilityElements(); >- if(extnElems == null) >- return; >- for(int i=0;i<extnElems.size();i++){ >- if(extnElems.get(i) instanceof SOAPBinding) >- { >- SOAPBinding soapBinding = (SOAPBinding) extnElems.get(i); >- isDocumentStyle = soapBinding.getStyle().equals("document"); >- break; >- } >- } >- >- List operations = binding.getEBindingOperations(); >- if(operations == null) >- return; >- >- for(int i=0;i<operations.size();i++){ >- BindingOperation operation = (BindingOperation) operations.get(i); >- validateBindingOperation(operation, isDocumentStyle); >- } >- } >- >- private void validateBindingOperation(BindingOperation operation, boolean isDocumentStyle){ >- if(operation == null) >- return; >- validateBindingInput(operation.getEBindingInput(), isDocumentStyle); >- validateBindingOutput(operation.getEBindingOutput(), isDocumentStyle); >- } >- >- private void validateBindingInput(BindingInput bindingInput, boolean isDocumentStyle){ >- if(bindingInput == null) >- return; >- List extnElems = bindingInput.getEExtensibilityElements(); >- if(extnElems == null) >- return; >- for(int i=0;i<extnElems.size();i++){ >- if(extnElems.get(i) instanceof SOAPBody) >- { >- SOAPBody soapBody = (SOAPBody) extnElems.get(i); >- boolean isLiteral = soapBody.getUse().equals("literal"); >- if(!(isDocumentStyle && isLiteral)){ >- IValidationMessage message = ValidationUtils.createNewErrorMessage(Messages.NOT_DOC_LITERAL_MESSAGE); >- _consolidatedReport.addValidationMessage(message); >- return; >- } >- } >- } >- } >- >- private void validateBindingOutput(BindingOutput bindingOutput, boolean isDocumentStyle){ >- if(bindingOutput == null) >- return; >- List extnElems = bindingOutput.getEExtensibilityElements(); >- if(extnElems == null) >- return; >- for(int i=0;i<extnElems.size();i++){ >- if(extnElems.get(i) instanceof SOAPBody) >- { >- SOAPBody soapBody = (SOAPBody) extnElems.get(i); >- boolean isLiteral = soapBody.getUse().equals("literal"); >- if(!(isDocumentStyle && isLiteral)){ >- IValidationMessage message = ValidationUtils.createNewErrorMessage(Messages.NOT_DOC_LITERAL_MESSAGE); >- _consolidatedReport.addValidationMessage(message); >- return; >- } >- } >- } >- } >- >+ // TODO Check for RMD exists and Descriptor exists >+ // TODO Check for All in same namespace >+ >+ performOperationsValidation(definition); >+ >+ performWsdlMessagesValidation(definition); >+ >+ performBindingValidation(definition); >+ } >+ >+ private void performOperationsValidation(Definition definition) >+ { >+ Definition2Capability def2Capability = new Definition2Capability( >+ definition, false, false, true, false); >+ Capability capability = def2Capability.getCapability(); >+ List operations = capability.getOperations(); >+ for (int i = 0; i < operations.size(); i++) >+ { >+ Operation operation = (Operation) operations.get(i); >+ validateResolvedOperation(operation); >+ String msg = CapUtils.validateJavaIdentifier(operation.getName()); >+ if (msg != null) >+ { >+ IValidationMessage message = ValidationUtils >+ .createNewErrorMessage(msg); >+ _consolidatedReport.addValidationMessage(message); >+ } >+ if (CapUtils.isOperationNameConflicted(operation.getName())) >+ { >+ msg = org.eclipse.tptp.wsdm.tooling.nls.messages.capability.operation.internal.Messages >+ .bind(CONFLICTED_OPERATION, operation.getName()); >+ IValidationMessage message = ValidationUtils >+ .createNewErrorMessage(msg); >+ _consolidatedReport.addValidationMessage(message); >+ } >+ } >+ // TODO Check for duplicate param name >+ // TODO Check for invalid param name >+ } >+ >+ private void validateResolvedOperation(Operation operation) >+ { >+ IValidationMessage unresolvedOperationMessage = ValidationUtils >+ .createNewErrorMessage(Messages.bind( >+ Messages.UNRESOLVED_OPERATION_MESSAGE, operation >+ .getName())); >+ if (operation.getEInput() != null) >+ { >+ if (operation.getEInput().getEMessage() == null) >+ _consolidatedReport >+ .addValidationMessage(unresolvedOperationMessage); >+ >+ } >+ else >+ _consolidatedReport >+ .addValidationMessage(unresolvedOperationMessage); >+ >+ if (operation.getEOutput() != null) >+ { >+ if (operation.getEOutput().getEMessage() == null) >+ _consolidatedReport >+ .addValidationMessage(unresolvedOperationMessage); >+ } >+ else >+ _consolidatedReport >+ .addValidationMessage(unresolvedOperationMessage); >+ } >+ >+ private void performRPElementValidation(Definition definition, >+ XSDElementDeclaration resourcePropertyElement) >+ { >+ if (resourcePropertyElement.getAnonymousTypeDefinition() == null) >+ return; >+ XSDComplexTypeDefinition typeDef = (XSDComplexTypeDefinition) resourcePropertyElement >+ .getAnonymousTypeDefinition(); >+ XSDModelGroup modelGroup = XsdUtils.getXSDModelGroup(typeDef); >+ XSDElementDeclaration[] elementRefs = XsdUtils >+ .getElementDeclarations(modelGroup); >+ for (int i = 0; i < elementRefs.length; i++) >+ { >+ if (XsdUtils.isReferencedElement(elementRefs[i])) >+ { >+ WsdlElementResolver resolver = new WsdlElementResolver( >+ definition, resourcePropertyElement, elementRefs[i]); >+ XSDElementDeclaration resolvedElement = resolver.resolve(); >+ if (resolvedElement == null) >+ { >+ String unresolvedElementName = elementRefs[i] >+ .getResolvedElementDeclaration().getName(); >+ IValidationMessage message = ValidationUtils >+ .createNewErrorMessage(NLS.bind( >+ Messages.UNRESOLVED_ELEMENT_MESSAGE, >+ unresolvedElementName)); >+ _consolidatedReport.addValidationMessage(message); >+ } >+ } >+ } >+ } >+ >+ private void performWsdlMessagesValidation(Definition definition) >+ { >+ if (definition == null) >+ return; >+ List messages = definition.getEMessages(); >+ if (messages != null) >+ { >+ for (int i = 0; i < messages.size(); i++) >+ { >+ Message message = (Message) messages.get(i); >+ if (message.getEParts() == null >+ || message.getEParts().size() == 0) >+ { >+ IValidationMessage valMessage = ValidationUtils >+ .createNewErrorMessage(Messages.bind( >+ Messages.WSDL_MESSAGE_ZERO_PART_MESSAGE, >+ message.getQName().getLocalPart())); >+ _consolidatedReport.addValidationMessage(valMessage); >+ continue; >+ } >+ >+ if (message.getEParts().size() > 1) >+ { >+ IValidationMessage valMessage = ValidationUtils >+ .createNewErrorMessage(Messages >+ .bind( >+ Messages.WSDL_MESSAGE_MORE_THAN_ONE_PART_MESSAGE, >+ message.getQName().getLocalPart())); >+ _consolidatedReport.addValidationMessage(valMessage); >+ } >+ } >+ } >+ List imports = definition.getEImports(); >+ if (imports != null) >+ { >+ for (int i = 0; i < imports.size(); i++) >+ { >+ Import theImport = (Import) imports.get(i); >+ if (theImport.getLocationURI().endsWith("wsdl")) >+ performWsdlMessagesValidation(theImport.getEDefinition()); >+ } >+ } >+ } >+ >+ private void performBindingValidation(Definition definition) >+ { >+ if (definition == null) >+ return; >+ List bindings = definition.getEBindings(); >+ if (bindings == null) >+ return; >+ for (int i = 0; i < bindings.size(); i++) >+ { >+ Binding binding = (Binding) bindings.get(i); >+ validateBinding(binding); >+ } >+ List imports = definition.getEImports(); >+ if (imports != null) >+ { >+ for (int i = 0; i < imports.size(); i++) >+ { >+ Import theImport = (Import) imports.get(i); >+ if (theImport.getLocationURI().endsWith("wsdl")) >+ performBindingValidation(theImport.getEDefinition()); >+ } >+ } >+ } >+ >+ private void validateBinding(Binding binding) >+ { >+ boolean isDocumentStyle = false; >+ List extnElems = binding.getEExtensibilityElements(); >+ if (extnElems == null) >+ return; >+ for (int i = 0; i < extnElems.size(); i++) >+ { >+ if (extnElems.get(i) instanceof SOAPBinding) >+ { >+ SOAPBinding soapBinding = (SOAPBinding) extnElems.get(i); >+ isDocumentStyle = soapBinding.getStyle().equals("document"); >+ break; >+ } >+ } >+ >+ List operations = binding.getEBindingOperations(); >+ if (operations == null) >+ return; >+ >+ for (int i = 0; i < operations.size(); i++) >+ { >+ BindingOperation operation = (BindingOperation) operations.get(i); >+ validateBindingOperation(operation, isDocumentStyle); >+ } >+ } >+ >+ private void validateBindingOperation(BindingOperation operation, >+ boolean isDocumentStyle) >+ { >+ if (operation == null) >+ return; >+ validateBindingInput(operation.getEBindingInput(), isDocumentStyle); >+ validateBindingOutput(operation.getEBindingOutput(), isDocumentStyle); >+ } >+ >+ private void validateBindingInput(BindingInput bindingInput, >+ boolean isDocumentStyle) >+ { >+ if (bindingInput == null) >+ return; >+ List extnElems = bindingInput.getEExtensibilityElements(); >+ if (extnElems == null) >+ return; >+ for (int i = 0; i < extnElems.size(); i++) >+ { >+ if (extnElems.get(i) instanceof SOAPBody) >+ { >+ SOAPBody soapBody = (SOAPBody) extnElems.get(i); >+ boolean isLiteral = soapBody.getUse().equals("literal"); >+ if (!(isDocumentStyle && isLiteral)) >+ { >+ IValidationMessage message = ValidationUtils >+ .createNewErrorMessage(Messages.NOT_DOC_LITERAL_MESSAGE); >+ _consolidatedReport.addValidationMessage(message); >+ return; >+ } >+ } >+ } >+ } >+ >+ private void validateBindingOutput(BindingOutput bindingOutput, >+ boolean isDocumentStyle) >+ { >+ if (bindingOutput == null) >+ return; >+ List extnElems = bindingOutput.getEExtensibilityElements(); >+ if (extnElems == null) >+ return; >+ for (int i = 0; i < extnElems.size(); i++) >+ { >+ if (extnElems.get(i) instanceof SOAPBody) >+ { >+ SOAPBody soapBody = (SOAPBody) extnElems.get(i); >+ boolean isLiteral = soapBody.getUse().equals("literal"); >+ if (!(isDocumentStyle && isLiteral)) >+ { >+ IValidationMessage message = ValidationUtils >+ .createNewErrorMessage(Messages.NOT_DOC_LITERAL_MESSAGE); >+ _consolidatedReport.addValidationMessage(message); >+ return; >+ } >+ } >+ } >+ } >+ > }
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 161932
:
52511
|
56198
|
57069
|
57084
| 57207 |
57493