Hi guys, just a question for you. I'm writing a WPF application that use the old MDI concept (one main page with severel detail pages), where I choose my root object (from the main page) and than open the details page. Every time a detail is open, I do a "BeginEdit" and every time it is closed I do a "ApplyEdit" or "CancelEdit", without executing Save() method. In my main page, there is a Confirm button (enabled by "IsSavable" property of the root object) and here there is the problem.
If I press Confirm button (that execute Save() method) how can I force ApplyEdit or CancelEdit in each open detail page before execute Save method? Is there a way to do it or do I need to loop through each open page, ask user if he want to save thus executing ApplyEdit or CancelEdit, and than save root object?
In an MDI application I would recommend to use BeginEdit/ApplyEdit/CancelEdit on the root object only.
There is no way to determine a sequence of how the form's are being edited and since the user calls Save on the root object - to me it is also the point of Cancel or Apply.
If you should call BeginEdit on the same object in 2 forms you are getting into trouble.
Really, if you allow multiple windows to edit the same object graph, you shouldn't use n-level undo at all. As Jonny says, there's no way to predict the order in which anything will occur, so there's no way to keep any parent-child edit levels in sync.
So unless the entire MDI form represents one root object, it isn't clear to me how you could use the feature at all.
Thanks guys for the help. Let me explain better.. My mdi form reppresent only one root object (choosed from a combobox within it). Once a root object is selected I let my user open several detail window. For example, root object is a Customer and each detail is an invoice. User open two details (invoice 10/01 and invoce 10/02) and then modify description of each invoices. Now he can press Ok button (doing ApplyEdit()) or Cancel Button (doing CancelEdit()), but what if he press SaveButton (on MDI form) before close each window? I was wondering if it's correct to ask him what action do (accept or cancel) in each page, keeping in mind that I can easily build an ordered list of open windows, and so loop throught it...
I forgot... each BeginEdit, ApplyEdit or CancelEdit is made in the root object
Let me put this another way.
If more than one active window points to the same object graph (a root or any of its child objects) you will encounter issues.
N-level undo is designed to support modal dialog windows or single window displays. MDI implies several non-modal windows pointing to the same object graph, and in that case you really can't use n-level undo (no calling of BeginEdit/CancelEdit/ApplyEdit per-window).
Ok, now it's clear! It's monday...
Thanks a lot, Enrico
Copyright (c) Marimer LLC