mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +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,
|
public String createUniqueName(ComponentType componentType,
|
||||||
Project currentProject) {
|
Project currentProject) {
|
||||||
int i = 0;
|
|
||||||
boolean exists = true;
|
boolean exists = true;
|
||||||
List<IDIYComponent<?>> components = currentProject.getComponents();
|
List<IDIYComponent<?>> components = currentProject.getComponents();
|
||||||
String[] takenNames = new String[components.size()];
|
String[] takenNames = new String[components.size()];
|
||||||
for (int j = 0; j < currentProject.getComponents().size(); j++) {
|
for (int j = 0; j < currentProject.getComponents().size(); j++) {
|
||||||
takenNames[j] = components.get(i).getName();
|
takenNames[j] = components.get(j).getName();
|
||||||
}
|
}
|
||||||
Arrays.sort(takenNames);
|
Arrays.sort(takenNames);
|
||||||
|
int i = 0;
|
||||||
while (exists) {
|
while (exists) {
|
||||||
i++;
|
i++;
|
||||||
String name = componentType.getNamePrefix() + i;
|
String name = componentType.getNamePrefix() + i;
|
||||||
exists = false;
|
exists = false;
|
||||||
if (Arrays.binarySearch(takenNames, name) >= 0) {
|
if (Arrays.binarySearch(takenNames, name) >= 0) {
|
||||||
exists = true;
|
exists = true;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return componentType.getNamePrefix() + i;
|
return componentType.getNamePrefix() + i;
|
||||||
|
|||||||
Reference in New Issue
Block a user