• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSUndoManager beginUndoGrouping and endUndoGrouping
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSUndoManager beginUndoGrouping and endUndoGrouping


  • Subject: Re: NSUndoManager beginUndoGrouping and endUndoGrouping
  • From: Marcos Trejo Munguia <email@hidden>
  • Date: Mon, 15 Jan 2007 19:02:16 -0600

Hi Chuck,

I tried the same thing but without a call to saveChanges, and the result was the same, how can I ensure that what I put between a beginUndoGrouping and endUndoGrouping is undone with a call to undoNestedGroup, in the documentation states the following:

"NSUndoManager normally creates undo groups automatically during the run loop. The first time it's asked to record an undo operation in the run loop, it creates a new group. Then, at the end of the loop, it closes the group. You can create additional, nested undo groups within these default groups using the beginUndoGrouping() and enableUndoRegistration() methods. You can also turn off the default grouping behavior using setGroupsByEvent(boolean)."

I also have tried setGroupsByEvent(false), but when i call beginUndoGrouping I get the next exception:

java.lang.IllegalStateException: _registerUndoObject: undo manager is in invalid state, must begin a group before registering undo

For now, and because the time is running out I will use revert.

BTW I believe that the excerpt from the documentation where it reads "beginUndoGrouping() and enableUndoRegistration() methods" should be "beginUndoGrouping() and endUndoGrouping() methods"

There's someone who had succeed with NSUndoManager?

Cheers

On Jan 15, 2007, at 5:18 PM, Chuck Hill wrote:

Hi Marcos,

My first thought is to use ec.revert() in the catch block, but perhaps is is undoing more than you want. The EC using the undo manager internally, so the state may not be what you expect when a save fails. I don't know if you can use it like that or not.

Chuck




On Jan 15, 2007, at 2:36 PM, Marcos Trejo Munguia wrote:

Dear List,

I have never used NSUndoManager at all, I read through the API documentation and maybe I didn't get the idea, I believed that beginUndoGrouping and endUndoGrouping were used to mark the beginning and the end of an undo group. I'm using beginUndoGrouping and endUndoGrouping as follows:

private EOEditingContext ec = new EOEditingContext();

public void select() {
	...
	ec.undoManager().beginUndoGrouping();
	....
}

public void save() {
	try {
		ec.saveChanges();
	} catch (Exception e) {
		ec.undoManager().endUndoGrouping();
		ec.undoManager().undoNestedGroup();
	}
}

What I see is almost everything in the editing context being undone.

Can somebody please tell me what am I doing wrong?

Thanks in advance!

Cheers

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
village.net


This email sent to email@hidden


--

Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
http://www.global-village.net/products/practical_webobjects






_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >NSUndoManager beginUndoGrouping and endUndoGrouping (From: Marcos Trejo Munguia <email@hidden>)
 >Re: NSUndoManager beginUndoGrouping and endUndoGrouping (From: Chuck Hill <email@hidden>)

  • Prev by Date: Re: NSUndoManager beginUndoGrouping and endUndoGrouping
  • Next by Date: WOFileUpload with UTF-8 forms
  • Previous by thread: Re: NSUndoManager beginUndoGrouping and endUndoGrouping
  • Next by thread: Re: NSUndoManager beginUndoGrouping and endUndoGrouping
  • Index(es):
    • Date
    • Thread