Skip to main content
summaryrefslogtreecommitdiffstats
path: root/jpa
diff options
context:
space:
mode:
authortle2010-04-27 21:21:15 +0000
committertle2010-04-27 21:21:15 +0000
commitaa882aeac898cb7929f4e8a5fea2668f21e61e9c (patch)
treee5013fe5b9408323460a06af3b4198a92987b0ca /jpa
parent04a0de3a9f63e61aa7daf7e99a1388503d683d91 (diff)
downloadwebtools.dali-aa882aeac898cb7929f4e8a5fea2668f21e61e9c.tar.gz
webtools.dali-aa882aeac898cb7929f4e8a5fea2668f21e61e9c.tar.xz
webtools.dali-aa882aeac898cb7929f4e8a5fea2668f21e61e9c.zip
310652 Duplicate Bindings Files allowed in JAXB class generation wizard
Diffstat (limited to 'jpa')
-rw-r--r--jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/classesgen/ClassesGeneratorWizardPage.java41
1 files changed, 20 insertions, 21 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/classesgen/ClassesGeneratorWizardPage.java b/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/classesgen/ClassesGeneratorWizardPage.java
index c618a71824..b5a997e600 100644
--- a/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/classesgen/ClassesGeneratorWizardPage.java
+++ b/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/classesgen/ClassesGeneratorWizardPage.java
@@ -73,6 +73,8 @@ import org.osgi.framework.Bundle;
*/
public class ClassesGeneratorWizardPage extends NewTypeWizardPage {
static public String JPT_ECLIPSELINK_UI_PLUGIN_ID = "org.eclipse.jpt.eclipselink.ui"; //$NON-NLS-1$
+ static public String XML_FILTER = "*.xml"; //$NON-NLS-1$
+ static public String XJB_FILTER = "*.xjb"; //$NON-NLS-1$
private final IJavaProject javaProject;
@@ -456,10 +458,10 @@ public class ClassesGeneratorWizardPage extends NewTypeWizardPage {
public void widgetSelected(SelectionEvent e) {
- String fileName = promptFile("*.xml");
- if( ! StringTools.stringIsEmpty(fileName)) {
+ String filePath = promptFile(XML_FILTER);
+ if( ! StringTools.stringIsEmpty(filePath)) {
- catalogText.setText(makeRelativeToProjectPath(fileName));
+ catalogText.setText(makeRelativeToProjectPath(filePath));
}
}
});
@@ -519,10 +521,10 @@ public class ClassesGeneratorWizardPage extends NewTypeWizardPage {
public void widgetSelected(SelectionEvent e) {
- String fileName = promptFile("*.xjb");
- if( ! StringTools.stringIsEmpty(fileName)) {
-
- tableDataModel.add(makeRelativeToProjectPath(fileName));
+ String filePath = promptFile(XJB_FILTER);
+ if( ! StringTools.stringIsEmpty(filePath)) {
+
+ addBindingsFile(filePath, tableDataModel);
tableViewer.refresh();
}
}
@@ -543,7 +545,7 @@ public class ClassesGeneratorWizardPage extends NewTypeWizardPage {
return;
}
String bindingsFileName = (String)selection.getFirstElement();
- removeBindingsFileName(bindingsFileName);
+ removeBindingsFile(bindingsFileName);
tableViewer.refresh();
}
@@ -558,19 +560,16 @@ public class ClassesGeneratorWizardPage extends NewTypeWizardPage {
IPath relativePath = path.makeRelativeTo(javaProject.getProject().getLocation());
return relativePath.toOSString();
}
-
- private void removeBindingsFileName(String bindingsName) {
- String name = this.getBindingsFileName(bindingsName);
- this.bindingsFileNames.remove(name);
+
+ private void addBindingsFile(String filePath, final ArrayList<String> tableDataModel) {
+ String relativePath = this.makeRelativeToProjectPath(filePath);
+ if( ! tableDataModel.contains(relativePath)) {
+ tableDataModel.add(relativePath);
+ }
}
- private String getBindingsFileName(String bindingsName) {
- for(String name: this.bindingsFileNames) {
- if(name.equals(bindingsName)) {
- return name;
- }
- }
- return null;
+ private void removeBindingsFile(String bindingsName) {
+ this.bindingsFileNames.remove(bindingsName);
}
private IBaseLabelProvider buildLabelProvider() {
@@ -585,13 +584,13 @@ public class ClassesGeneratorWizardPage extends NewTypeWizardPage {
* The Add button was clicked, its action invokes this action which should
* prompt the user to select a file and return it.
*/
- private String promptFile(String extension) {
+ private String promptFile(String filter) {
String projectPath= javaProject.getProject().getLocation().toString();
FileDialog dialog = new FileDialog(getShell());
dialog.setText(JptJaxbUiMessages.ClassesGeneratorWizardPage_chooseABindingsFile);
dialog.setFilterPath(projectPath);
- dialog.setFilterExtensions(new String[] {extension}); //$NON-NLS-1$
+ dialog.setFilterExtensions(new String[] {filter});
String filePath = dialog.open();
return (filePath != null) ? filePath : null;

Back to the top