// loop through the resources for this module
for (Iterator<WorkspaceResource> it = ((GemDesignStore)designManager.getResourceStore()).getResourceIterator(moduleName); it.hasNext(); ) {
WorkspaceResource designResource = it.next();
GemDesign gemDesign = GemDesign.loadGemDesign(designResource, new Status("Load Design Status"));
Document designDoc = gemDesign.getDesignDocument();
Document oldDesignDoc = (Document)designDoc.cloneNode(true);
boolean changesMade = updateDesignDocument(designDoc, gemDesign.getDesignName(), moduleNameResolver);
if (changesMade) {
if (!designManager.getResourceStore().isWriteable(new ResourceName(CALFeatureName.getFunctionFeatureName(gemDesign.getDesignName())))) {
throw new RenamingException("Can not update the design for " + gemDesign.getDesignName().getQualifiedName() + " because it is not writeable.");
}
Status saveGemStatus = new Status("Save gem design status");
workspace.saveDesign(gemDesign, saveGemStatus);
if (saveGemStatus.getSeverity().equals(Status.Severity.ERROR)) {
throw new RenamingException("Error saving the updated design for " + gemDesign.getDesignName().getQualifiedName() + ".");
}
undoList.add(new Pair<GemDesign, Document>(gemDesign, oldDesignDoc));
}
}
}
// Return true if the undoList has contents (ie. changes have been made)
return !undoList.isEmpty();
} catch (RenamingException e) {
status.add(new Status(Status.Severity.ERROR, e.getErrorMessage()));
for (int i = undoList.size() - 1; i >= 0; i--) {
Pair<GemDesign, Document> designDocPair = undoList.get(i);
GemDesign gemDesign = designDocPair.fst();
Document oldDesignDoc = designDocPair.snd();
replaceDocumentChildren(gemDesign.getDesignDocument(), oldDesignDoc);
Status undoStatus = new Status("Undo design update status");
workspace.saveDesign(gemDesign, undoStatus);
if (undoStatus.getSeverity().equals(Status.Severity.ERROR)) {
String msg = "FATAL: Error undoing the design update for " + gemDesign.getDesignName().getQualifiedName();
status.add(new Status(Status.Severity.ERROR, msg));
}
}
return false;
}