}
protected boolean validateId(XMLPanel pnl, XMLElement el) {
XMLComplexElement cel = null;
String newId = null;
XMLPanel idPanel = null;
if (el instanceof XMLAttribute) {
XMLElement parent = el.getParent();
if (parent instanceof XMLCollectionElement) {
cel = (XMLCollectionElement) parent;
newId = cel.get("Id").toValue();
if (pnl.getValue() instanceof String) {
newId = ((String) pnl.getValue()).trim();
idPanel = pnl;
}
} else if (parent instanceof Package) {
cel = (Package) parent;
newId = cel.get("Id").toValue();
if (pnl.getValue() instanceof String) {
newId = ((String) pnl.getValue()).trim();
idPanel = pnl;
}
}
} else if (el instanceof XMLComplexElement) {
cel = (XMLComplexElement) el;
newId = cel.get("Id").toValue();
idPanel = findPanel(pnl, cel.get("Id"));
if (idPanel != null) {
if (idPanel.getValue() instanceof String) {
newId = ((String) idPanel.getValue()).trim();
}
}
}
System.err.println("Valid for " + el + ", par=" + el.getParent() + ", newid=" + newId + ", idp=" + idPanel);
boolean isValid = XMLUtil.isIdValid(newId);
//check for period (.)
if(isValid && newId.contains(".")){
isValid = false;
}
if (!isValid) {
XMLBasicPanel.errorMessage(pnl.getWindow(), ResourceManager.getLanguageDependentString("ErrorMessageKey"), "",
ResourceManager.getLanguageDependentString(XPDLValidationErrorIds.ERROR_INVALID_ID));
idPanel.requestFocus();
return false;
}
if (cel != null) {
boolean isUniqueId = true;
if (cel instanceof XMLCollectionElement) {
isUniqueId = JaWEManager.getInstance().getIdFactory().isIdUnique((XMLCollectionElement) cel, newId);
} else {
Package fp = JaWEManager.getInstance().getXPDLHandler().getPackageById(newId);
if (fp != null && fp != cel && fp.getId().equals(newId)) {
isUniqueId = false;
}
}
if (!isUniqueId) {
XMLBasicPanel.errorMessage(pnl.getWindow(), ResourceManager.getLanguageDependentString("ErrorMessageKey"),
"", ResourceManager.getLanguageDependentString(XPDLValidationErrorIds.ERROR_NON_UNIQUE_ID));
idPanel.requestFocus();
return false;
}
}
return true;
}