Component naming bug fix

This commit is contained in:
bancika
2012-08-24 15:58:14 +00:00
parent bb22ef61ff
commit ddfac76b58
@@ -175,22 +175,21 @@ public class InstantiationManager {
}
public String createUniqueName(ComponentType componentType,
Project currentProject) {
int i = 0;
Project currentProject) {
boolean exists = true;
List<IDIYComponent<?>> components = currentProject.getComponents();
String[] takenNames = new String[components.size()];
for (int j = 0; j < currentProject.getComponents().size(); j++) {
takenNames[j] = components.get(i).getName();
takenNames[j] = components.get(j).getName();
}
Arrays.sort(takenNames);
int i = 0;
while (exists) {
i++;
String name = componentType.getNamePrefix() + i;
exists = false;
if (Arrays.binarySearch(takenNames, name) >= 0) {
exists = true;
break;
exists = true;
}
}
return componentType.getNamePrefix() + i;