diff options
author | tle | 2011-07-22 20:07:14 +0000 |
---|---|---|
committer | tle | 2011-07-22 20:07:14 +0000 |
commit | 114d427a4f5d3a607a7745494dfdb250af532d88 (patch) | |
tree | 547fddfe1fa410bb5f69ba617e8450181ccc1b01 | |
parent | a7c78a82815994f1163cbbdfb056bcfa8e893382 (diff) | |
download | webtools.dali-114d427a4f5d3a607a7745494dfdb250af532d88.tar.gz webtools.dali-114d427a4f5d3a607a7745494dfdb250af532d88.tar.xz webtools.dali-114d427a4f5d3a607a7745494dfdb250af532d88.zip |
351423 - XML Schema from Java-Class is tried to be exported to a wrong (not existent) path
2 files changed, 24 insertions, 16 deletions
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/schemagen/NewSchemaFileWizardPage.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/schemagen/NewSchemaFileWizardPage.java index c384630021..eca8f1777b 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/schemagen/NewSchemaFileWizardPage.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/schemagen/NewSchemaFileWizardPage.java @@ -84,8 +84,17 @@ public class NewSchemaFileWizardPage extends WizardNewFileCreationPage { return (IProject) this.dataModel.getProperty(PROJECT); } - public IPath getFilePath() { - return this.getContainerFullPath(); + /** + * @return the path of the schema file relative to the project + */ + public IPath getFileRelativePath() { + IPath filePath = this.getContainerFullPath(); + String projectName = filePath.segment(0); + + if(this.getProject().getName().equals(projectName)) { + filePath = filePath.removeFirstSegments(1); + } + return filePath; } // ********** validation ********** diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/schemagen/SchemaGeneratorWizard.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/schemagen/SchemaGeneratorWizard.java index 977d6d809a..7b1dc1c747 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/schemagen/SchemaGeneratorWizard.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/schemagen/SchemaGeneratorWizard.java @@ -22,7 +22,6 @@ import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.OperationCanceledException; -import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.SubMonitor; import org.eclipse.jdt.core.IJavaElement; @@ -149,21 +148,21 @@ public class SchemaGeneratorWizard extends Wizard implements INewWizard } private String getTargetSchema() { - - IPath filePath = this.newSchemaFileWizardPage.getFilePath(); + + IPath filePath = this.newSchemaFileWizardPage.getFileRelativePath(); String fileName = this.newSchemaFileWizardPage.getFileName(); - String targetSchema = filePath.toOSString() + File.separator + fileName; - if ( ! FileTools.extension(targetSchema).equalsIgnoreCase(XSD_EXTENSION)) { - targetSchema += XSD_EXTENSION; - } - - return this.makeRelativeToProjectPath(targetSchema); + String targetSchema = (filePath.isEmpty()) ? + fileName : + filePath.toOSString() + File.separator + fileName; + + return this.addXsdExtension(targetSchema); } - - private String makeRelativeToProjectPath(String filePath) { - Path path = new Path(filePath); - IPath relativePath = path.makeRelativeTo(this.targetProject.getProject().getLocation()); - return relativePath.removeFirstSegments(1).toOSString(); + + private String addXsdExtension(String fileName) { + + return (FileTools.extension(fileName).equalsIgnoreCase(XSD_EXTENSION)) ? + fileName : + fileName + XSD_EXTENSION; } private Object[] getAllCheckedItems() { |