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 58849 Details for
Bug 165544
WSDM Tooling: Enhanced importing of WSDLs and schemas
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Updated patch
patch_13_02_07.txt (text/plain), 40.61 KB, created by
Saurabh Dravid
on 2007-02-13 08:19:28 EST
(
hide
)
Description:
Updated patch
Filename:
MIME Type:
Creator:
Saurabh Dravid
Created:
2007-02-13 08:19:28 EST
Size:
40.61 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.tptp.wsdm.editor >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/wsdl/OperationImportWizardPage.java >=================================================================== >RCS file: /cvsroot/ganges/org.eclipse.tptp.wsdm.editor/src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/wsdl/OperationImportWizardPage.java,v >retrieving revision 1.1 >diff -u -r1.1 OperationImportWizardPage.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/wsdl/OperationImportWizardPage.java 8 Feb 2007 19:40:12 -0000 1.1 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/wsdl/OperationImportWizardPage.java 13 Feb 2007 13:13:09 -0000 >@@ -21,7 +21,6 @@ > import javax.wsdl.Operation; > import javax.wsdl.PortType; > >-import org.eclipse.emf.common.util.URI; > import org.eclipse.jface.dialogs.Dialog; > import org.eclipse.jface.viewers.CheckStateChangedEvent; > import org.eclipse.jface.viewers.CheckboxTreeViewer; >@@ -49,8 +48,7 @@ > private Definition _wsdlDefinition; > private PortType[] _existingPortTypes = new PortType[0]; > private Operation[] _importedOperations; >- private URI _importedWsdlURI; >- >+ > public OperationImportWizardPage() > { > super("ImportOperationWizardPage"); >@@ -137,7 +135,7 @@ > // _viewer.expandToLevel(2); > // Checked the Port types provided by constructor > doIntialCheckedElements(); >- _viewer.setGrayedElements(_existingPortTypes); >+ //_viewer.setGrayedElements(_existingPortTypes); > updateStatus(null); > } > >@@ -147,16 +145,6 @@ > initialize(); > } > >- public void setImportedWsdlURI(URI importedWsdlURI) >- { >- _importedWsdlURI = importedWsdlURI; >- } >- >- public URI getImportedWsdlURI() >- { >- return _importedWsdlURI; >- } >- > private List getConsolidatedPortList(PortType[] ports) > { > List portTypes = new LinkedList(); >@@ -172,7 +160,10 @@ > protected void doIntialCheckedElements() > { > for (int i = 0; i < _existingPortTypes.length; i++) >+ { > _viewer.setSubtreeChecked(_existingPortTypes[i], true); >+ } >+ > } > > private void handleCheckStateChanged(CheckStateChangedEvent event) >@@ -195,8 +186,9 @@ > return; > } > } >- >+ _viewer.setGrayChecked(event.getElement(), false); > _viewer.setSubtreeChecked(event.getElement(), event.getChecked()); >+ changeParentCheckStatus(event.getElement()); > Operation[] checkedOperations = getCheckedOperations(); > OperationImportValidator validator = new OperationImportValidator( > checkedOperations); >@@ -212,6 +204,39 @@ > } > _importedOperations = getSelectedOperation(); > } >+ >+ private void changeParentCheckStatus(Object checkedElement) >+ { >+ Object parent = _contentProvider.getParent(checkedElement); >+ if(parent == null) >+ return; >+ Object[] childrens = _contentProvider.getChildren(parent); >+ int checkedChildrensSize = 0; >+ for(int i=0;i<childrens.length;i++) >+ { >+ if(_viewer.getChecked(childrens[i])) >+ checkedChildrensSize++; >+ } >+ // If all childrens checked, make the parent checked >+ if(checkedChildrensSize == childrens.length) >+ { >+ _viewer.setGrayChecked(parent, false); >+ _viewer.setChecked(parent, true); >+ return; >+ } >+ // If not all but any one of the childrens checked, make the parent grayed >+ if(checkedChildrensSize>0) >+ { >+ _viewer.setGrayChecked(parent, true); >+ return; >+ } >+ // If none of them is checked, then make the parent unchecked >+ if(checkedChildrensSize == 0) >+ { >+ _viewer.setGrayChecked(parent, false); >+ return; >+ } >+ } > > private void updateStatus(String message) > { >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/wsdl/OperationImportWizard.java >=================================================================== >RCS file: /cvsroot/ganges/org.eclipse.tptp.wsdm.editor/src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/wsdl/OperationImportWizard.java,v >retrieving revision 1.1 >diff -u -r1.1 OperationImportWizard.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/wsdl/OperationImportWizard.java 8 Feb 2007 19:40:12 -0000 1.1 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/wsdl/OperationImportWizard.java 13 Feb 2007 13:13:09 -0000 >@@ -29,6 +29,7 @@ > import org.eclipse.tptp.wsdm.tooling.editor.capability.internal.CapabilityDomain; > import org.eclipse.tptp.wsdm.tooling.editor.internal.CapabilityDefinition; > import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.imports.internal.Messages; >+import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmToolingLog; > import org.eclipse.ui.INewWizard; > import org.eclipse.ui.IWorkbench; > >@@ -44,6 +45,7 @@ > private Definition _wsdlDefinition; > private PortType[] _existingPortTypes = new PortType[0]; > private OperationImportWizardPage _importPage; >+ private URI _importedWsdlURI; > > public OperationImportWizard(CapabilityDomain capabilityDomain, > Definition definition) >@@ -83,7 +85,7 @@ > } > catch (Exception e) > { >- e.printStackTrace(); >+ WsdmToolingLog.logError(e.getMessage(), e); > } > return false; > } >@@ -93,9 +95,8 @@ > Operation[] importOperations = _importPage.getImportedOperations(); > CapabilityDefinition capabilityDefinition = (CapabilityDefinition) _capabilityDomain > .getCapability().getWsdlDefinition(); >- URI importedWsdlURI = _importPage.getImportedWsdlURI(); > ImportOperationCommand command = new ImportOperationCommand( >- capabilityDefinition, importOperations, importedWsdlURI, monitor); >+ capabilityDefinition, _wsdlDefinition, importOperations, _importedWsdlURI, monitor); > command.execute(); > Operation[] newOperations = command.getNewOperations(); > _capabilityDomain.getCapability().getOperations().addAll( >@@ -108,6 +109,6 @@ > > public void setImportedWsdlURI(URI importedWsdlURI) > { >- _importPage.setImportedWsdlURI(importedWsdlURI); >+ _importedWsdlURI = importedWsdlURI; > } > } >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/wsdl/XSDSchemaMerger.java >=================================================================== >RCS file: /cvsroot/ganges/org.eclipse.tptp.wsdm.editor/src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/wsdl/XSDSchemaMerger.java,v >retrieving revision 1.1 >diff -u -r1.1 XSDSchemaMerger.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/wsdl/XSDSchemaMerger.java 8 Feb 2007 19:40:12 -0000 1.1 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/wsdl/XSDSchemaMerger.java 13 Feb 2007 13:13:09 -0000 >@@ -32,11 +32,13 @@ > > private XSDSchema _schema; > private List _allResultedSchema; >+ private List _allAddedSchemaURIs; > > public XSDSchemaMerger(XSDSchema schema) > { > _schema = schema; > _allResultedSchema = new LinkedList(); >+ _allAddedSchemaURIs = new LinkedList(); > addSchema(_schema); > } > >@@ -74,15 +76,23 @@ > > private void addSchema(XSDSchema givenSchema) > { >- XSDSchema schema = getSchema(givenSchema.getTargetNamespace()); >+ if(isAlreadyAdded(givenSchema)) >+ return; >+ XSDSchema clonedSchema = (XSDSchema) givenSchema.cloneConcreteComponent(true, true); >+ clonedSchema.setSchemaLocation(givenSchema.getSchemaLocation()); >+ XSDSchema schema = getSchema(clonedSchema.getTargetNamespace()); > if (schema != null) >- { >- List givenSchemaContents = givenSchema.getContents(); >- for (int i = 0; i < givenSchemaContents.size(); i++) >- schema.getContents().add(givenSchemaContents.get(i)); >- } >+ schema.getContents().addAll(clonedSchema.getContents()); > else >- _allResultedSchema.add(givenSchema); >+ _allResultedSchema.add(clonedSchema); >+ String schemaLocation = clonedSchema.getSchemaLocation(); >+ _allAddedSchemaURIs.add(schemaLocation); >+ } >+ >+ private boolean isAlreadyAdded(XSDSchema givenSchema) >+ { >+ String schemaLocation = givenSchema.getSchemaLocation(); >+ return _allAddedSchemaURIs.contains(schemaLocation); > } > > private XSDSchema getSchema(String targetNamespace) >Index: src/org/eclipse/tptp/wsdm/tooling/editor/ui/internal/namegenerator/NewWSDLMessageNameGenerator.java >=================================================================== >RCS file: /cvsroot/ganges/org.eclipse.tptp.wsdm.editor/src/org/eclipse/tptp/wsdm/tooling/editor/ui/internal/namegenerator/NewWSDLMessageNameGenerator.java,v >retrieving revision 1.1 >diff -u -r1.1 NewWSDLMessageNameGenerator.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/ui/internal/namegenerator/NewWSDLMessageNameGenerator.java 8 Feb 2007 19:40:12 -0000 1.1 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/ui/internal/namegenerator/NewWSDLMessageNameGenerator.java 13 Feb 2007 13:13:09 -0000 >@@ -23,14 +23,14 @@ > public class NewWSDLMessageNameGenerator implements INewNameGenerator > { > private Definition _definition; >- private String _namePattern; >+ private String _pattern; > > public NewWSDLMessageNameGenerator(Definition definition, String namePattern) > { > _definition = definition; > if (namePattern == null || namePattern.trim().equals("")) > namePattern = "NewMessage"; >- _namePattern = namePattern; >+ _pattern = namePattern; > } > > public NewWSDLMessageNameGenerator(Definition definition) >@@ -41,12 +41,13 @@ > public String getNewName() > { > int count = 0; >- while (WsdlUtils.getWSDLMessage(_definition, _namePattern) != null) >+ String namePattern = _pattern+count; >+ while (WsdlUtils.getWSDLMessage(_definition, namePattern) != null) > { >- _namePattern = _namePattern + count; > count++; >+ namePattern = _pattern+count; > } >- return _namePattern; >+ return namePattern; > } > > } >Index: src/org/eclipse/tptp/wsdm/tooling/editor/ui/internal/namegenerator/NewXSDElementNameGenerator.java >=================================================================== >RCS file: /cvsroot/ganges/org.eclipse.tptp.wsdm.editor/src/org/eclipse/tptp/wsdm/tooling/editor/ui/internal/namegenerator/NewXSDElementNameGenerator.java,v >retrieving revision 1.1 >diff -u -r1.1 NewXSDElementNameGenerator.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/ui/internal/namegenerator/NewXSDElementNameGenerator.java 8 Feb 2007 19:40:12 -0000 1.1 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/ui/internal/namegenerator/NewXSDElementNameGenerator.java 13 Feb 2007 13:13:10 -0000 >@@ -22,14 +22,14 @@ > public class NewXSDElementNameGenerator implements INewNameGenerator > { > private XSDSchema _schema; >- private String _namePattern; >+ private String _pattern; > > public NewXSDElementNameGenerator(XSDSchema schema, String namePattern) > { > _schema = schema; > if (namePattern == null || namePattern.trim().equals("")) > namePattern = "NewElement"; >- _namePattern = namePattern; >+ _pattern = namePattern; > } > > public NewXSDElementNameGenerator(XSDSchema schema) >@@ -40,12 +40,13 @@ > public String getNewName() > { > int count = 0; >- while (XsdUtils.getXSDElementDeclarationOfName(_schema, _namePattern) != null) >+ String namePattern = _pattern+count; >+ while (XsdUtils.getXSDElementDeclarationOfName(_schema, namePattern) != null) > { >- _namePattern = _namePattern + count; > count++; >+ namePattern = _pattern+count; > } >- return _namePattern; >+ return namePattern; > } > > } >Index: src/org/eclipse/tptp/wsdm/tooling/editor/ui/internal/namegenerator/NewIFileNameGenerator.java >=================================================================== >RCS file: /cvsroot/ganges/org.eclipse.tptp.wsdm.editor/src/org/eclipse/tptp/wsdm/tooling/editor/ui/internal/namegenerator/NewIFileNameGenerator.java,v >retrieving revision 1.1 >diff -u -r1.1 NewIFileNameGenerator.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/ui/internal/namegenerator/NewIFileNameGenerator.java 8 Feb 2007 19:40:12 -0000 1.1 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/ui/internal/namegenerator/NewIFileNameGenerator.java 13 Feb 2007 13:13:09 -0000 >@@ -26,15 +26,22 @@ > { > private IResource _resource; > private String _namePattern; >+ private String _fileName; >+ private String _fileExtension; > > public NewIFileNameGenerator(IResource resource, String namePattern) > { > _resource = resource; >- if (namePattern == null || namePattern.trim().equals("")) >- namePattern = "NewFile.tmp"; >- if (namePattern.indexOf('.') == -1) >+ if (namePattern == null || namePattern.trim().equals("") || namePattern.indexOf('.') == -1) > { > namePattern = "NewFile.tmp"; >+ _fileName = "NewFile"; >+ _fileExtension = "tmp"; >+ } >+ else >+ { >+ _fileName = namePattern.substring(0,namePattern.lastIndexOf('.')); >+ _fileExtension = namePattern.substring(namePattern.lastIndexOf('.')+1); > } > _namePattern = namePattern; > } >@@ -70,11 +77,7 @@ > int count = 0; > while (isFileExists(members, _namePattern)) > { >- String fileNameWithoutExtn = _namePattern.substring(0, _namePattern >- .lastIndexOf('.')); >- String fileExtn = _namePattern.substring(_namePattern >- .lastIndexOf('.') + 1); >- _namePattern = fileNameWithoutExtn + count + "." + fileExtn; >+ _namePattern = _fileName + count + "." + _fileExtension; > count++; > } > return _namePattern; >Index: src/org/eclipse/tptp/wsdm/tooling/wizard/capability/internal/NewCapabilityWizard.java >=================================================================== >RCS file: /cvsroot/ganges/org.eclipse.tptp.wsdm.editor/src/org/eclipse/tptp/wsdm/tooling/wizard/capability/internal/NewCapabilityWizard.java,v >retrieving revision 1.2 >diff -u -r1.2 NewCapabilityWizard.java >--- src/org/eclipse/tptp/wsdm/tooling/wizard/capability/internal/NewCapabilityWizard.java 9 Feb 2007 06:30:07 -0000 1.2 >+++ src/org/eclipse/tptp/wsdm/tooling/wizard/capability/internal/NewCapabilityWizard.java 13 Feb 2007 13:13:10 -0000 >@@ -19,6 +19,7 @@ > import java.util.HashMap; > import java.util.Map; > >+import javax.wsdl.Definition; > import javax.wsdl.Operation; > import javax.wsdl.PortType; > import javax.wsdl.Types; >@@ -94,10 +95,6 @@ > > private IFile _capFile; > >- private boolean canContinue = true; >- >- private boolean isOverwriteXSD = true; >- > private final static String DEFAULT_DESCRIPTION = "Example capability"; > > /** >@@ -195,29 +192,6 @@ > _options.put(CapabilityWizardKeys.IMPORT_OPERATION_KEY, > importedOperations); > >- 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) >@@ -248,26 +222,23 @@ > } > }; > >- if (canContinue) >+ try > { >- 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; >- } >+ 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; > } > >@@ -275,8 +246,7 @@ > IOException, InvocationTargetException, InterruptedException > { > verifyContainer(); >- if (isOverwriteXSD) >- doFinishXSD(monitor); >+ doFinishXSD(monitor); > doFinishRMD(monitor); > doFinishCapFile(monitor); > refreshContainer(monitor); >@@ -288,55 +258,6 @@ > // TODO Put the code to verify container > } > >- private void shouldOverWriteXSD() >- { >- // TODO >- // 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 >- // { >- // 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 > { >@@ -493,8 +414,7 @@ > String capNS = (String) _options.get(CapabilityWizardKeys.CAP_NS_KEY); > XSDSchema schema = _wsdlCapDefinition.createOrFindSchema(capNS); > createAnnotation(schema); >- if (isOverwriteXSD) >- createPropXSDInclude(schema); >+ createPropXSDInclude(schema); > createResourceProperties(schema); > } > >@@ -551,9 +471,10 @@ > .get(CapabilityWizardKeys.IMPORT_OPERATION_KEY); > if(importOperations.length!=0) > { >- URI importedWsdlURI = _importOperationPage.getImportedWsdlURI(); >+ URI importedWsdlURI = _importerPage.getImportedWsdlURI(); >+ Definition importedWsdlDefinition = _importerPage.getImportedWsdlDefinition(); > ImportOperationCommand command = new ImportOperationCommand( >- _wsdlCapDefinition, importOperations, importedWsdlURI); >+ _wsdlCapDefinition, importedWsdlDefinition, importOperations, importedWsdlURI); > command.execute(); > } > } >Index: src/org/eclipse/tptp/wsdm/tooling/wizard/capability/internal/CapabilityModelImporterPage.java >=================================================================== >RCS file: /cvsroot/ganges/org.eclipse.tptp.wsdm.editor/src/org/eclipse/tptp/wsdm/tooling/wizard/capability/internal/CapabilityModelImporterPage.java,v >retrieving revision 1.1 >diff -u -r1.1 CapabilityModelImporterPage.java >--- src/org/eclipse/tptp/wsdm/tooling/wizard/capability/internal/CapabilityModelImporterPage.java 8 Feb 2007 19:40:13 -0000 1.1 >+++ src/org/eclipse/tptp/wsdm/tooling/wizard/capability/internal/CapabilityModelImporterPage.java 13 Feb 2007 13:13:10 -0000 >@@ -13,11 +13,14 @@ > package org.eclipse.tptp.wsdm.tooling.wizard.capability.internal; > > import javax.wsdl.Definition; >-import javax.wsdl.Operation; >+import javax.wsdl.WSDLException; >+import javax.wsdl.factory.WSDLFactory; >+import javax.wsdl.xml.WSDLReader; > > import org.eclipse.core.resources.IFile; > import org.eclipse.core.resources.IWorkspaceRoot; > import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.Path; > import org.eclipse.emf.common.util.URI; > import org.eclipse.jface.dialogs.Dialog; >@@ -40,12 +43,12 @@ > import org.eclipse.tptp.wsdm.tooling.dialog.provisional.XSDBrowseDialog; > import org.eclipse.tptp.wsdm.tooling.editor.capability.imports.wsdl.OperationImportWizardPage; > import org.eclipse.tptp.wsdm.tooling.editor.capability.imports.xsd.PropertyImportWizardPage; >-import org.eclipse.tptp.wsdm.tooling.editor.internal.CapabilityDefinition; > import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.internal.Messages; > import org.eclipse.tptp.wsdm.tooling.util.internal.EclipseUtils; >-import org.eclipse.tptp.wsdm.tooling.util.internal.WsdlUtils; >+import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmToolingLog; > import org.eclipse.tptp.wsdm.tooling.util.internal.XsdUtils; > import org.eclipse.xsd.XSDSchema; >+import org.xml.sax.InputSource; > > /** > * Wizard page to import capability from XSD and WSDL files. >@@ -71,11 +74,11 @@ > > private Button _browseWSDL; > >- private Object[] _checkedItems; >- >- private Operation[] _importedOperations = new Operation[0]; >- > private boolean _canFlipToNextPage = false; >+ >+ private URI _importedWsdlURI = null; >+ >+ private Definition _importedWsdlDefinition = null; > > /** > * Creates new object of this class. >@@ -275,9 +278,9 @@ > if (dialog.open() == Window.OK) > { > IFile browsedFile = (IFile) dialog.getFirstResult(); >- XSDSchema xsdSchema = XsdUtils.getSchema(browsedFile); >- _xsdFilePathText.setText(browsedFile.getFullPath().toString()); > // TODO Check for valid file >+ XsdUtils.getSchema(browsedFile); >+ _xsdFilePathText.setText(browsedFile.getFullPath().toString()); > } > } > >@@ -289,10 +292,11 @@ > IFile browsedFile = (IFile) dialog.getFirstResult(); > try > { >- WsdlUtils.getCapabilityDefinition(browsedFile); >+ getWsdlDefinition(browsedFile); > } > catch (Exception e) > { >+ WsdmToolingLog.logError(e.getMessage(), e); > MessageDialog > .openError( > getShell(), >@@ -303,24 +307,16 @@ > _wsdlFilePathText.setText(browsedFile.getFullPath().toString()); > } > } >- >- /** >- * Returns the imported XSD schemas specified. >- */ >- /* >- * protected XSDSchema[] getSchemaToImport() { >- * if(_emptyCapability.getSelection() || _fromWSDL.getSelection()) return >- * new XSDSchema[0]; return new XSDSchema[0]; } >- */ >- >- /** >- * Returns the imported Operations specified. >- */ >- /* >- * protected Operation[] getOperationsToImport() { >- * if(_emptyCapability.getSelection() || _fromXSD.getSelection()) return new >- * Operation[0]; return _importedOperations; } >- */ >+ >+ private Definition getWsdlDefinition(IFile file) throws WSDLException, CoreException >+ { >+ WSDLFactory factory = WSDLFactory.newInstance(); >+ WSDLReader reader = factory.newWSDLReader(); >+ InputSource inputSource = new InputSource(file.getContents()); >+ String fileLocation = file.getLocation().toString(); >+ Definition definition = reader.readWSDL(fileLocation, inputSource); >+ return definition; >+ } > > private void dialogChanged() > { >@@ -396,20 +392,17 @@ > _wizard.getPropertyImportWizardPage().setPageComplete(true); > String wsdlFilePath = getWSDLFilePath(); > IFile wsdlFile = EclipseUtils.getIFile(wsdlFilePath); >- CapabilityDefinition capabilityDefinition = WsdlUtils >- .getCapabilityDefinition(wsdlFile); >- Definition wsdlDefinition = capabilityDefinition >- .getDefinition(); >+ _importedWsdlDefinition = getWsdlDefinition(wsdlFile); > OperationImportWizardPage page = _wizard > .getOperationImportWizardPage(); >- page.setWSDLDefinition(wsdlDefinition); >- page.setImportedWsdlURI(URI.createPlatformResourceURI(wsdlFile.getFullPath().toString())); >+ page.setWSDLDefinition(_importedWsdlDefinition); >+ _importedWsdlURI = URI.createPlatformResourceURI(wsdlFile.getFullPath().toString()); > setPageComplete(true); > return page; > } > catch (Exception e) > { >- e.printStackTrace(); >+ WsdmToolingLog.logError(e.getMessage(), e); > } > } > if (_fromXSD.getSelection()) >@@ -428,7 +421,7 @@ > } > catch (Exception e) > { >- e.printStackTrace(); >+ WsdmToolingLog.logError(e.getMessage(), e); > } > } > return super.getNextPage(); >@@ -453,4 +446,14 @@ > { > return _fromWSDL.getSelection(); > } >+ >+ public URI getImportedWsdlURI() >+ { >+ return _importedWsdlURI; >+ } >+ >+ public Definition getImportedWsdlDefinition() >+ { >+ return _importedWsdlDefinition; >+ } > } >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/xsd/PropertyImportWizard.java >=================================================================== >RCS file: /cvsroot/ganges/org.eclipse.tptp.wsdm.editor/src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/xsd/PropertyImportWizard.java,v >retrieving revision 1.1 >diff -u -r1.1 PropertyImportWizard.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/xsd/PropertyImportWizard.java 8 Feb 2007 19:40:11 -0000 1.1 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/xsd/PropertyImportWizard.java 13 Feb 2007 13:13:09 -0000 >@@ -28,6 +28,7 @@ > import org.eclipse.tptp.wsdm.tooling.editor.capability.internal.CapabilityDomain; > import org.eclipse.tptp.wsdm.tooling.model.capabilities.Property; > import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.imports.internal.Messages; >+import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmToolingLog; > import org.eclipse.ui.INewWizard; > import org.eclipse.ui.IWorkbench; > import org.eclipse.xsd.XSDElementDeclaration; >@@ -81,7 +82,7 @@ > } > catch (Exception e) > { >- e.printStackTrace(); >+ WsdmToolingLog.logError(e.getMessage(), e); > } > return false; > } >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/xsd/PropertyImportWizardPage.java >=================================================================== >RCS file: /cvsroot/ganges/org.eclipse.tptp.wsdm.editor/src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/xsd/PropertyImportWizardPage.java,v >retrieving revision 1.1 >diff -u -r1.1 PropertyImportWizardPage.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/xsd/PropertyImportWizardPage.java 8 Feb 2007 19:40:11 -0000 1.1 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/xsd/PropertyImportWizardPage.java 13 Feb 2007 13:13:09 -0000 >@@ -126,7 +126,7 @@ > // _viewer.expandToLevel(2); > // Checked the Schemas provided by constructor > doIntialCheckedElements(); >- _viewer.setGrayedElements(_existingPropertyNs); >+ //_viewer.setGrayedElements(_existingPropertyNs); > updateStatus(null); > } > >@@ -157,7 +157,9 @@ > } > } > >+ _viewer.setGrayChecked(event.getElement(), false); > _viewer.setSubtreeChecked(event.getElement(), event.getChecked()); >+ changeParentCheckStatus(event.getElement()); > Property[] checkedProperties = getCheckedProperties(); > PropertyImportValidator validator = new PropertyImportValidator( > checkedProperties); >@@ -173,6 +175,39 @@ > } > _importedProperties = getSelectedProperties(); > } >+ >+ private void changeParentCheckStatus(Object checkedElement) >+ { >+ Object parent = _contentProvider.getParent(checkedElement); >+ if(parent == null) >+ return; >+ Object[] childrens = _contentProvider.getChildren(parent); >+ int checkedChildrensSize = 0; >+ for(int i=0;i<childrens.length;i++) >+ { >+ if(_viewer.getChecked(childrens[i])) >+ checkedChildrensSize++; >+ } >+ // If all childrens checked, make the parent checked >+ if(checkedChildrensSize == childrens.length) >+ { >+ _viewer.setGrayChecked(parent, false); >+ _viewer.setChecked(parent, true); >+ return; >+ } >+ // If not all but any one of the childrens checked, make the parent grayed >+ if(checkedChildrensSize>0) >+ { >+ _viewer.setGrayChecked(parent, true); >+ return; >+ } >+ // If none of them is checked, then make the parent unchecked >+ if(checkedChildrensSize == 0) >+ { >+ _viewer.setGrayChecked(parent, false); >+ return; >+ } >+ } > > private void updateStatus(String message) > { >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/property/internal/ImportPropertyCommand.java >=================================================================== >RCS file: /cvsroot/ganges/org.eclipse.tptp.wsdm.editor/src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/property/internal/ImportPropertyCommand.java,v >retrieving revision 1.1 >diff -u -r1.1 ImportPropertyCommand.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/property/internal/ImportPropertyCommand.java 8 Feb 2007 19:40:11 -0000 1.1 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/property/internal/ImportPropertyCommand.java 13 Feb 2007 13:13:09 -0000 >@@ -88,24 +88,6 @@ > { > // Get the location for Imported XSD Schema in local drive format > XSDSchema importSchema = importedProperty.getElement().getSchema(); >- // String schemaLocation = >- // XsdUtils.getLocalSystemSchemaLocation(importSchema); >- >- // Get the location for capability file >- // String capFileLocation = null; >- // try { >- // capFileLocation = >- // WsdlUtils.getLocalSystemWSDLLocation(_capabilityDefinition); >- // } catch (CoreException e) { >- // e.printStackTrace(); >- // } >- >- // Create xsd:import element >- // String importSchemaLocation = EclipseUtils.getRelativePath( >- // capFileLocation, schemaLocation, '/'); >- // XsdUtils.createImportStatement(_resourcePropertyElement.getSchema(), >- // importSchema.getTargetNamespace(), importSchemaLocation); >- > XsdUtils.createImportStatement(_resourcePropertyElement.getSchema(), > importSchema.getTargetNamespace(), importSchema.eResource() > .getURI().toString()); >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/operation/internal/NewParameterDialog.java >=================================================================== >RCS file: /cvsroot/ganges/org.eclipse.tptp.wsdm.editor/src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/operation/internal/NewParameterDialog.java,v >retrieving revision 1.1 >diff -u -r1.1 NewParameterDialog.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/operation/internal/NewParameterDialog.java 8 Feb 2007 19:40:11 -0000 1.1 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/operation/internal/NewParameterDialog.java 13 Feb 2007 13:13:09 -0000 >@@ -218,6 +218,9 @@ > paramName = nameGenerator.getNextName(); > } > } >+ else if(paramName == null) >+ paramName = ""; >+ > _paramName.setText(paramName); > > DataTypesCollection instance = DataTypesCollection.getInstance(); >@@ -249,6 +252,8 @@ > for (int i = 0; i < _paramList.size(); i++) > { > InputParameter param = (InputParameter) _paramList.get(i); >+ if(param.getXSDElementDeclaration().getName() == null) >+ continue; > if (param.getXSDElementDeclaration().getName().equals( > newParamName)) > instances++; >@@ -260,6 +265,8 @@ > for (int i = 0; i < _paramList.size(); i++) > { > InputParameter param = (InputParameter) _paramList.get(i); >+ if(param.getXSDElementDeclaration().getName() == null) >+ continue; > if (param.getXSDElementDeclaration().getName().equals(newParamName)) > return true; > } >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/operation/internal/ImportOperationCommand.java >=================================================================== >RCS file: /cvsroot/ganges/org.eclipse.tptp.wsdm.editor/src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/operation/internal/ImportOperationCommand.java,v >retrieving revision 1.1 >diff -u -r1.1 ImportOperationCommand.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/operation/internal/ImportOperationCommand.java 8 Feb 2007 19:40:12 -0000 1.1 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/operation/internal/ImportOperationCommand.java 13 Feb 2007 13:13:09 -0000 >@@ -13,13 +13,16 @@ > package org.eclipse.tptp.wsdm.tooling.editor.capability.command.operation.internal; > > import java.util.ArrayList; >+import java.util.Arrays; > import java.util.Iterator; > import java.util.LinkedList; > import java.util.List; > import java.util.Map; >+import java.util.Vector; > > import javax.wsdl.Definition; > import javax.wsdl.Fault; >+import javax.wsdl.Import; > import javax.wsdl.Input; > import javax.wsdl.Message; > import javax.wsdl.Operation; >@@ -39,6 +42,7 @@ > import org.eclipse.tptp.wsdm.tooling.editor.internal.CapabilityDefinition; > import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.imports.internal.Messages; > 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; > import org.eclipse.xsd.XSDElementDeclaration; > import org.eclipse.xsd.XSDImport; >@@ -54,28 +58,31 @@ > public class ImportOperationCommand > { > private CapabilityDefinition _capabilityDefinition; >+ private Definition _importDefinition; > private Definition _definition; > private Operation[] _importedOperations; > private URI _importedWsdlURI; > private List _newOperations; > private IProgressMonitor _monitor; > private XSDSchema[] _importedWsdlSchemas = new XSDSchema[0]; >+ private QName WSA_ACTION_QNAME = new QName(WsdmConstants.WSA_URI, >+ WsdmConstants.WSA_ACTION_NAME); > > /** > * Creates a new object of this class. > */ >- public ImportOperationCommand(CapabilityDefinition capabilityDefinition, >+ public ImportOperationCommand(CapabilityDefinition capabilityDefinition,Definition importDefinition, > Operation[] importedOperations, URI importedWsdlURI, IProgressMonitor monitor) > { > _capabilityDefinition = capabilityDefinition; > _definition = _capabilityDefinition.getDefinition(); >+ _importDefinition = importDefinition; > _importedWsdlURI = importedWsdlURI; > _importedOperations = importedOperations; > _newOperations = new LinkedList(); > _monitor = monitor; >- _importedWsdlSchemas = loadSchemas(_importedWsdlURI); >- XSDSchema[] capabilityWsdlSchemas = _capabilityDefinition >- .getXSDSchemas(); >+ _importedWsdlSchemas = loadSchemas(); >+ //XSDSchema[] capabilityWsdlSchemas = _capabilityDefinition.getXSDSchemas(); > // TODO > /* > * if(capabilityWsdlSchemas == null) // No wsdl types defined { Types >@@ -90,10 +97,10 @@ > /** > * Creates a new object of this class. > */ >- public ImportOperationCommand(CapabilityDefinition capabilityDefinition, >+ public ImportOperationCommand(CapabilityDefinition capabilityDefinition,Definition importDefinition, > Operation[] importedOperations, URI importedWsdlURI) > { >- this(capabilityDefinition, importedOperations, importedWsdlURI, null); >+ this(capabilityDefinition, importDefinition, importedOperations, importedWsdlURI, null); > } > > /** >@@ -103,6 +110,8 @@ > { > _monitor.beginTask(Messages.IMPORTING_OPERATIONS, > _importedOperations.length); >+ _definition.addNamespace(WsdmConstants.WSA_PREFIX, >+ WsdmConstants.WSA_URI); > for (int i = 0; i < _importedOperations.length; i++) > { > String taskName = Messages.bind(Messages.IMPORTING_OPERATION, >@@ -142,16 +151,16 @@ > newInput.setMessage(newMessage); > _capabilityDefinition.addMessage(newMessage); > >- // TODO >- /* >- * String opName = importedOperation.getName(); opName = >- * opName.substring(0, 1).toUpperCase() + opName.substring(1); String >- * tns = _capabilityDefinition.getTargetNamespace(); >- * if(!tns.endsWith("/")) tns = tns+"/"; String action = >- * tns+opName+"Request"; >- * newInput.getElement().setAttributeNS(WsdmConstants.WSA_URI, >- * WsdmConstants.WSA_ACTION_NAME, action); >- */ >+ String action = getAction(newInput.getMessage()); >+ newInput.setExtensionAttribute(WSA_ACTION_QNAME, action); >+ } >+ >+ 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; > } > > private void createNewOperationOutput(Operation newOperation, >@@ -168,17 +177,9 @@ > Message newMessage = createNewMessage(importedMessage); > newOutput.setMessage(newMessage); > _capabilityDefinition.addMessage(newMessage); >- >- // TODO >- /* >- * String opName = importedOperation.getName(); opName = >- * opName.substring(0, 1).toUpperCase() + opName.substring(1); String >- * tns = _capabilityDefinition.getTargetNamespace(); >- * if(!tns.endsWith("/")) tns = tns+"/"; String action = >- * tns+opName+"Response"; >- * newOutput.getElement().setAttributeNS(WsdmConstants.WSA_URI, >- * WsdmConstants.WSA_ACTION_NAME, action); >- */ >+ >+ String action = getAction(newOutput.getMessage()); >+ newOutput.setExtensionAttribute(WSA_ACTION_QNAME, action); > } > > private void createNewOperationFaults(Operation newOperation, >@@ -220,24 +221,39 @@ > Part part = definition.createPart(); > message.addPart(part); > Part importedPart = (Part)importedMessage.getParts().values().iterator().next(); >- XSDSchema importedPartSchema = getImportedWSDLSchema(importedPart.getElementName().getNamespaceURI()); >- importSchemaForElement(importedPartSchema); >- String xsdNS = importedPart.getElementName().getNamespaceURI(); >- String elementName = importedPart.getElementName().getLocalPart(); >- XSDSchema elementSchema = _capabilityDefinition.getSchema(xsdNS); >- XSDElementDeclaration element = XsdUtils.getXSDElementDeclarationOfName(elementSchema, elementName); >- _capabilityDefinition.createOrFindPrefix(element.getTargetNamespace(), null); > part.setName(importedPart.getName()); >- part.setElementName(new QName(xsdNS, elementName)); >+ if(importedPart.getElementName()!=null) >+ { >+ XSDSchema importedPartSchema = getImportedWSDLSchema(importedPart.getElementName().getNamespaceURI()); >+ importSchemaForElement(importedPartSchema); >+ String xsdNS = importedPart.getElementName().getNamespaceURI(); >+ String elementName = importedPart.getElementName().getLocalPart(); >+ XSDSchema elementSchema = _capabilityDefinition.getSchema(xsdNS); >+ XSDElementDeclaration element = XsdUtils.getXSDElementDeclarationOfName(elementSchema, elementName); >+ _capabilityDefinition.createOrFindPrefix(element.getTargetNamespace(), null); >+ part.setElementName(new QName(xsdNS, elementName)); >+ } >+ else if(importedPart.getTypeName()!=null) >+ { >+ String xsdNS = importedPart.getTypeName().getNamespaceURI(); >+ String localName = importedPart.getTypeName().getLocalPart(); >+ part.setTypeName(new QName(xsdNS, localName)); >+ } > return message; > } > > private XSDSchema getImportedWSDLSchema(String namespace) > { > for(int i=0;i<_importedWsdlSchemas.length;i++) >- { > if(_importedWsdlSchemas[i].getTargetNamespace().equals(namespace)) > return _importedWsdlSchemas[i]; >+ >+ for(int i=0;i<_importedWsdlSchemas.length;i++) >+ { >+ XSDImport theImports[] = XsdUtils.getAllXSDImports(_importedWsdlSchemas[i]); >+ for(int j=0;j<theImports.length;j++) >+ if(theImports[j].getNamespace().equals(namespace)) >+ return theImports[j].getResolvedSchema(); > } > return null; > } >@@ -272,16 +288,22 @@ > XSDSchema copySchema = (XSDSchema) schema.cloneConcreteComponent(true, > false); > List contents = copySchema.getContents(); >+ List includes = new LinkedList(); >+ List imports = new LinkedList(); > for (int i = 0; i < contents.size(); i++) > { > if (contents.get(i) instanceof XSDInclude) >- contents.remove(i); >+ includes.add(contents.get(i)); > else if (contents.get(i) instanceof XSDImport) > { >- XSDImport theImport = (XSDImport) contents.get(i); >+ XSDImport theImport = (XSDImport) contents.get(i); > theImport.setSchemaLocation(null); >+ imports.add(theImport); > } > } >+ contents.removeAll(includes); >+ contents.removeAll(imports); >+ contents.addAll(0, imports); > copySchema.updateElement(true); > return copySchema; > } >@@ -292,6 +314,37 @@ > .toArray(new Operation[_newOperations.size()]); > } > >+ private XSDSchema[] loadSchemas() >+ { >+ List schemasList = new LinkedList(); >+ XSDSchema[] schemas = loadSchemas(_importedWsdlURI); >+ schemasList.addAll(Arrays.asList(schemas)); >+ >+ Map importsMap = _importDefinition.getImports(); >+ if(importsMap == null || importsMap.size() == 0) >+ return (XSDSchema[]) schemasList.toArray(new XSDSchema[0]); >+ >+ Iterator it = importsMap.values().iterator(); >+ while(it.hasNext()) >+ { >+ Object object = it.next(); >+ if(object instanceof Vector) >+ { >+ Vector vector = (Vector) object; >+ for(int i=0;i<vector.size();i++) >+ { >+ Import wsdlImport = (Import) vector.get(i); >+ String locationURI = wsdlImport.getLocationURI(); >+ URI wsdlURI = URI.createURI(_importedWsdlURI.trimSegments(1).toString()+"/"+locationURI); >+ XSDSchema[] importedSchemas = loadSchemas(wsdlURI); >+ schemasList.addAll(Arrays.asList(importedSchemas)); >+ } >+ } >+ } >+ >+ return (XSDSchema[]) schemasList.toArray(new XSDSchema[0]); >+ } >+ > private XSDSchema[] loadSchemas(URI uri) > { > // Get a ResourceSet describing the XSD in the WSDL
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 165544
:
58038
|
58095
|
58849
|
59774
|
64199