Author: bfitzpat
Date: 2010-10-07 13:27:08 -0400 (Thu, 07 Oct 2010)
New Revision: 25575
Modified:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/JBossWSCreationUtils.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateWizard.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateWizardValidator.java
Log:
JBIDE-6831: cannot create sample web service with an existing name in a different package
https://jira.jboss.org/browse/JBIDE-6831 - now we check for the fully qualified path name
with the class and package in it instead of just looking for a particular file name
without the package
Modified:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/JBossWSCreationUtils.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/JBossWSCreationUtils.java 2010-10-07
17:15:09 UTC (rev 25574)
+++
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/JBossWSCreationUtils.java 2010-10-07
17:27:08 UTC (rev 25575)
@@ -75,6 +75,7 @@
"synchronized", "this", "throw", "throws",
"transient", "true", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
//$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
"try", "void", "volatile", "while" };
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
static final String WEBINF = "WEB-INF"; //$NON-NLS-1$
+ private static String JAVA = ".java"; //$NON-NLS-1$
public static boolean isJavaKeyword(String keyword) {
if (hasUpperCase(keyword)) {
@@ -445,6 +446,30 @@
return path;
}
+ public static String composeSrcPackageClassPath ( IProject project, String packageName,
String className) {
+ String classFilePath = null;
+ try {
+ String srcPath = JBossWSCreationUtils.getJavaProjectSrcLocation(project);
+ if (srcPath != null && srcPath.trim().length() > 0) {
+ String pathSeparator = "" + File.separatorChar; //$NON-NLS-1$
+ String packageToFolderPath = packageName.replace(".", pathSeparator);
//$NON-NLS-1$
+ classFilePath = srcPath + pathSeparator + packageToFolderPath + pathSeparator +
className + JAVA;
+ return classFilePath;
+ }
+ } catch (JavaModelException e) {
+ return null;
+ }
+ return null;
+
+ }
+
+ public static File findFileByPath(String path) {
+ File file = new File(path);
+ if (file.exists())
+ return file;
+ return null;
+ }
+
public static File findFileByPath(String name, String path) {
File ret = null;
File folder = new File(path);
Modified:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateWizard.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateWizard.java 2010-10-07
17:15:09 UTC (rev 25574)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateWizard.java 2010-10-07
17:27:08 UTC (rev 25575)
@@ -87,8 +87,14 @@
model.setUpdateWebxml(true);
model.setCustomPackage(getPackageName());
- File file = JBossWSCreationUtils.findFileByPath(getClassName() + JAVA, project
- .getLocation().toOSString());
+ String classFilePath =
+ JBossWSCreationUtils.composeSrcPackageClassPath(project, model.getCustomPackage(),
className);
+ File file = null;
+ if (classFilePath != null)
+ file = JBossWSCreationUtils.findFileByPath(classFilePath);
+ else
+ file = JBossWSCreationUtils.findFileByPath(className + JAVA,
+ project.getLocation().toOSString());
if (file != null) {
MessageDialog
.openError(
Modified:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateWizardValidator.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateWizardValidator.java 2010-10-07
17:15:09 UTC (rev 25574)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossWSGenerateWizardValidator.java 2010-10-07
17:27:08 UTC (rev 25575)
@@ -160,7 +160,13 @@
if (status != null && status.getSeverity() == IStatus.ERROR) {
return status;
}
- File file = JBossWSCreationUtils.findFileByPath(className + JAVA,
+ String classFilePath =
+ JBossWSCreationUtils.composeSrcPackageClassPath(project, model.getCustomPackage(),
className);
+ File file = null;
+ if (classFilePath != null)
+ file = JBossWSCreationUtils.findFileByPath(classFilePath);
+ else
+ file = JBossWSCreationUtils.findFileByPath(className + JAVA,
project.getLocation().toOSString());
if (file != null) {
// class already exists