mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 01:32:08 +10:00
Component naming bug fix
This commit is contained in:
+4
-5
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user