//0. Correct the UUID at the client first
if (_idChgd != null) {
for (Iterator it = _idChgd.entrySet().iterator(); it.hasNext();) {
final Map.Entry me = (Map.Entry)it.next();
final Component comp = (Component)me.getKey();
if (!_attached.contains(comp))
responses.add(new AuUuid(comp, (String)me.getValue()));
}
_idChgd = null; //just in case
}
//1. process dead comonents, cropping and the removed page
final Map croppingInfos;
{
//1a. handle _detached to remove unncessary detach
doDetached();
//after call, _detached is merged to _moved
//1b. handle _moved
//The reason to remove first: some insertion might fail if the old
//componetns are not removed yet
//Also, we have to remove both parent and child because, at
//the client, they might not be parent-child relationship
Set removed = doMoved(responses);
//after called, _moved is cleared (add to _attached if necessary)
//And, AuRemove is generated (we have to generate AuRemove first,
//since UUID might be reused)
//1c. remove reduntant
removeRedundant(_invalidated);
removeRedundant(_attached);
removeCrossRedundant();
//1d. process Cropper
croppingInfos = doCrop();
//1d. prepare removed pages and optimize for invalidate or removed pages
checkPageRemoved(removed); //maintain _pgRemoved for pages being removed
}
//2. Process removed and invalid pages
//2a. clean up _invalidated and others belonging to invalid pages
if (_pgInvalid != null && _pgInvalid.isEmpty()) _pgInvalid = null;
if (_pgRemoved != null && _pgRemoved.isEmpty()) _pgRemoved = null;
if (_pgInvalid != null || _pgRemoved != null) {
clearInInvalidPage(_invalidated);
clearInInvalidPage(_attached);
clearInInvalidPage(_smartUpdated.keySet());
}
//2b. remove pages. Note: we don't need to generate rm, becausee they
//are included pages.
if (_pgRemoved != null) {
final DesktopCtrl dtctl = (DesktopCtrl)_exec.getDesktop();
for (final Iterator it = _pgRemoved.iterator(); it.hasNext();)
dtctl.removePage((Page)it.next());
}
//3. generate response for invalidated pages
if (_pgInvalid != null) {
for (final Iterator it = _pgInvalid.iterator(); it.hasNext();) {
final Page page = (Page)it.next();
responses.add(new AuOuter(page, redraw(page)));
}
}
/* if (log.finerable())
log.finer("After removing redudant: invalidated: "+_invalidated
+"\nAttached: "+_attached+"\nSmartUpd:"+_smartUpdated);
*/
//4. process special interfaces
//5. generate replace for invalidated
for (Iterator it = _invalidated.iterator(); it.hasNext();) {
final Component comp = (Component)it.next();
responses.add(new AuOuter(comp, redraw(comp)));
}
_ending = true; //no more addSmartUpdate...
//6. add attached components (including setParent)
//Due to cyclic references, we have to process all siblings
//at the same time
final List desktops = new LinkedList();
final Component[] attached = (Component[])
_attached.toArray(new Component[_attached.size()]);
for (int j = 0; j < attached.length; ++j) {
final Component comp = attached[j];
//Note: attached comp might change from another page to
//the one being created. In this case, no need to add
if (comp != null) {
final Page page = comp.getPage();
if (page != null && _exec.isAsyncUpdate(page)) {
final Component parent = comp.getParent();
final Set newsibs = new LinkedHashSet(32);
newsibs.add(comp);
desktops.add(newsibs);
for (int k = j + 1; k < attached.length; ++k) {
final Component ck = attached[k];
if (ck != null && ck.getParent() == parent) {
newsibs.add(ck);
attached[k] = null;
}
}
}