commited for NA
diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/plugin/WTPCommonMessages.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/plugin/WTPCommonMessages.java
index 52a8c47..ae44f9f 100644
--- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/plugin/WTPCommonMessages.java
+++ b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/plugin/WTPCommonMessages.java
@@ -42,4 +42,5 @@
public static final String PROJECT_EXISTS_AT_LOCATION_ERROR = "32"; //$NON-NLS-1$
public static final String ERR_EMPTY_MODULE_NAME = "34"; //$NON-NLS-1$
public static final String ERR_INVALID_CHARS = "34"; //$NON-NLS-1$
+ public static final String DUPLICATE_COMPONENT_NAME="36";//$NON-NLS-1$
}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.frameworks/src/wtp_common.properties b/plugins/org.eclipse.wst.common.frameworks/src/wtp_common.properties
index 9606b02..f5db865 100644
--- a/plugins/org.eclipse.wst.common.frameworks/src/wtp_common.properties
+++ b/plugins/org.eclipse.wst.common.frameworks/src/wtp_common.properties
@@ -42,4 +42,5 @@
32=A project already exists on the file system at this location: {0}. Either use "Import Existing Projects into Workspace" to create a project at this location or delete the contents of {0} from the file system.
33=A model instance may only be nested once under another model instance.
34=Module name cannot be empty.
-35=Invalid characters.
\ No newline at end of file
+35=Invalid characters.
+36=The module with this name already exists.
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/operation/ComponentCreationDataModel.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/operation/ComponentCreationDataModel.java
index 867277f..9311e2d 100644
--- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/operation/ComponentCreationDataModel.java
+++ b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/operation/ComponentCreationDataModel.java
@@ -18,6 +18,8 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.jem.util.emf.workbench.ProjectUtilities;
+import org.eclipse.wst.common.componentcore.StructureEdit;
+import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent;
import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants;
import org.eclipse.wst.common.frameworks.internal.operations.WTPOperationDataModel;
import org.eclipse.wst.common.frameworks.internal.operations.WTPOperationDataModelEvent;
@@ -155,6 +157,7 @@
String errorMessage = WTPCommonPlugin.getResourceString(WTPCommonMessages.ERR_EMPTY_MODULE_NAME);
return WTPCommonPlugin.createErrorStatus(errorMessage);
}
+ return checkForDuplicateName(moduleName);
} else
return status;
@@ -171,6 +174,28 @@
}
return super.doValidateProperty(propertyName);
}
+
+ protected IStatus checkForDuplicateName(String componentName){
+
+ IStatus status = OK_STATUS;
+ StructureEdit structureEdit = null;
+ try{
+
+ structureEdit = StructureEdit.getStructureEditForRead(getProject());
+ WorkbenchComponent component = structureEdit.findComponentByName(componentName);
+ if( component != null ){
+
+ String errorMessage = WTPCommonPlugin.getResourceString(WTPCommonMessages.DUPLICATE_COMPONENT_NAME);
+ status = WTPCommonPlugin.createErrorStatus(errorMessage);
+ }
+
+ }finally{
+ if (null != structureEdit) {
+ structureEdit.dispose();
+ }
+ }
+ return status;
+ }
private IStatus validateComponentVersionProperty() {
int componentVersion = getIntProperty(COMPONENT_VERSION);