public void addWidgetDefinition(WidgetDefinition widgetDefinition) throws DuplicateIdException {
String id = widgetDefinition.getId();
// Do not add NewDefinition id's hash.
if (!(widgetDefinition instanceof NewDefinition)) {
if (widgetDefinitionsById.containsKey(id)) {
Location duplicateLocation = widgetDefinition.getLocation();
Location containerLocation = containerDefinition.getLocation();
Location firstLocation = getWidgetDefinition(id).getLocation();
throw new DuplicateIdException(
"Duplicate widget id \"" + id + "\" detected at " + duplicateLocation + ".\n" +
"Container widget \"" + containerDefinition.getId() + "\" at " + containerLocation + "\n" +
"already contains a widget with id \"" + id + "\" at " + firstLocation + ".");
}