}
public TypeDeclaration createXPDLObject(TypeDeclarations tds,
String type,
boolean addToCollection) {
TypeDeclaration td = (TypeDeclaration) tds.generateNewElement();
adjustType(td, type);
JaWETypes jts = JaWEManager.getInstance().getJaWEController().getJaWETypes();
boolean hasTemplate = jts.hasTemplateId(type);
if (hasTemplate) {
jts.fillFromTemplate(td, type);
}
String id = td.getId();
if (!hasTemplate || id.equals("") || tds.getTypeDeclaration(id) != null) {
if (id.equals("")) {
id = JaWEManager.getInstance().getIdFactory().generateUniqueId(tds);
} else {
id = JaWEManager.getInstance().getIdFactory().generateSimilarOrIdenticalUniqueId(tds, new HashSet(), id);
}
int i = 0;
while (tds.getTypeDeclaration(id) != null) {
id = id + String.valueOf(++i);
}
td.setId(id);
}
adjustXPDLObject(td, type);
if (addToCollection) {