How to get into undo-chain?

Hi,

Is it possible to prompt the user before an undo is performed,
such as the larger refactorings, e.g. "Undo Copy class?", do?

Another question:
It seems like the undo is bound to the files/editors that are
modified by a command. Is it possible to associate a command
with an editor, even if the command does not change its contents?
Or, even better, is there some sort of project-global undo?

Background: I'm currently working on a taglib-editor that allows
editing of taglib descriptors. If I invoke an action in a specific
tag-class I want to edit the definition of, it would be nice if the
modifications to the TLD could be undone without switching to it.


Thanks,
Sascha


4 comments
Comment actions Permalink

All commands are separated into 2 groups: "simple" ones that only modify the
content of one document and "complex" ones that either modify multiple
documents or create/delete/etc files. Also a command can be forced to be
"complex" even when it modifies only one document (there is a special call
for this, although it's not in the Open API yet).

All simple commands are undone separately in each document. All complex
commands forms one "global" queue. Undoing any complex command requires user
confirmation. When "Undo" action is invoked anywhere outside the editor, the
last command from the "global" queue is undone. When it is invoked from the
editor, the last command affecting this document (either complex or simple)
is undone.

Possible solutions for your problem:
1. We open an API for making the current command "complex". This way it will
be undone from anywhere and undo will require a confirmation.
2. We change code of Undo action so that it takes "current document" not
only from editor but e.g. by taking some data from DataContext (which you
will be able to provide by your component).

Which one suits your needs better?

--
Valentin Kipiatkov
JetBrains, Inc
http://www.intellij.com
"Develop with pleasure!"

"Sascha Weinreuter" <sascha.weinreuter@cit.de> wrote in message
news:as7g6q$m3n$1@is.intellij.net...

Hi,

>

Is it possible to prompt the user before an undo is performed,
such as the larger refactorings, e.g. "Undo Copy class?", do?

>

Another question:
It seems like the undo is bound to the files/editors that are
modified by a command. Is it possible to associate a command
with an editor, even if the command does not change its contents?
Or, even better, is there some sort of project-global undo?

>

Background: I'm currently working on a taglib-editor that allows
editing of taglib descriptors. If I invoke an action in a specific
tag-class I want to edit the definition of, it would be nice if the
modifications to the TLD could be undone without switching to it.

>
>

Thanks,
Sascha

>
>


0
Comment actions Permalink

Hi,

thank you very much for your detailed reply.

After thinking about your suggestions, I think that having "complex"
commands without modifying several documents would be a good start,
because there also may be other plugins which make larger changes to a
document, and the user should be prompted before undoing them.

While your first suggestion is clear to me, I'm not sure how the second
one would work. I guess that it would somehow work by intercepting
the $Undo/$Redo editor actions. But here I see some difficulties in
determining when to pass the other document, because there may be
'normal' changes to the current document after my action - unless it's
possible to determine which command is about to be undone.


Thanks for your help,
Sascha


"Valentin Kipiatkov" <valentin@intellij.com> schrieb im Newsbeitrag
news:as83i4$1vv$1@is.intellij.net...

All commands are separated into 2 groups: "simple" ones that only modify the
content of one document and "complex" ones that either modify multiple
documents or create/delete/etc files. Also a command can be forced to be
"complex" even when it modifies only one document (there is a special call
for this, although it's not in the Open API yet).

>

All simple commands are undone separately in each document. All complex
commands forms one "global" queue. Undoing any complex command requires user
confirmation. When "Undo" action is invoked anywhere outside the editor, the
last command from the "global" queue is undone. When it is invoked from the
editor, the last command affecting this document (either complex or simple)
is undone.

>

Possible solutions for your problem:
1. We open an API for making the current command "complex". This way it will
be undone from anywhere and undo will require a confirmation.
2. We change code of Undo action so that it takes "current document" not
only from editor but e.g. by taking some data from DataContext (which you
will be able to provide by your component).

>

Which one suits your needs better?

>

--
Valentin Kipiatkov
JetBrains, Inc
http://www.intellij.com
"Develop with pleasure!"

>

"Sascha Weinreuter" <sascha.weinreuter@cit.de> wrote in message
news:as7g6q$m3n$1@is.intellij.net...

Hi,

>

Is it possible to prompt the user before an undo is performed,
such as the larger refactorings, e.g. "Undo Copy class?", do?

>

Another question:
It seems like the undo is bound to the files/editors that are
modified by a command. Is it possible to associate a command
with an editor, even if the command does not change its contents?
Or, even better, is there some sort of project-global undo?

>

Background: I'm currently working on a taglib-editor that allows
editing of taglib descriptors. If I invoke an action in a specific
tag-class I want to edit the definition of, it would be nice if the
modifications to the TLD could be undone without switching to it.

>
>

Thanks,
Sascha

>
>

>
>


0
Comment actions Permalink

We'll implement some API for this in Aurora. See
http://www.intellij.net/tracker/idea/viewSCR?publicId=7932

--
Valentin Kipiatkov
JetBrains, Inc
http://www.intellij.com
"Develop with pleasure!"

"Sascha Weinreuter" <sascha.weinreuter@cit.de> wrote in message
news:asb0ge$nrd$1@is.intellij.net...

Hi,

>

thank you very much for your detailed reply.

>

After thinking about your suggestions, I think that having "complex"
commands without modifying several documents would be a good start,
because there also may be other plugins which make larger changes to a
document, and the user should be prompted before undoing them.

>

While your first suggestion is clear to me, I'm not sure how the second
one would work. I guess that it would somehow work by intercepting
the $Undo/$Redo editor actions. But here I see some difficulties in
determining when to pass the other document, because there may be
'normal' changes to the current document after my action - unless it's
possible to determine which command is about to be undone.

>
>

Thanks for your help,
Sascha

>
>

"Valentin Kipiatkov" <valentin@intellij.com> schrieb im Newsbeitrag
news:as83i4$1vv$1@is.intellij.net...

All commands are separated into 2 groups: "simple" ones that only modify

the

content of one document and "complex" ones that either modify multiple
documents or create/delete/etc files. Also a command can be forced to be
"complex" even when it modifies only one document (there is a special

call

for this, although it's not in the Open API yet).

>

All simple commands are undone separately in each document. All complex
commands forms one "global" queue. Undoing any complex command requires

user

confirmation. When "Undo" action is invoked anywhere outside the editor,

the

last command from the "global" queue is undone. When it is invoked from

the

editor, the last command affecting this document (either complex or

simple)

is undone.

>

Possible solutions for your problem:
1. We open an API for making the current command "complex". This way it

will

be undone from anywhere and undo will require a confirmation.
2. We change code of Undo action so that it takes "current document" not
only from editor but e.g. by taking some data from DataContext (which

you

will be able to provide by your component).

>

Which one suits your needs better?

>

--
Valentin Kipiatkov
JetBrains, Inc
http://www.intellij.com
"Develop with pleasure!"

>

"Sascha Weinreuter" <sascha.weinreuter@cit.de> wrote in message
news:as7g6q$m3n$1@is.intellij.net...

Hi,

>

Is it possible to prompt the user before an undo is performed,
such as the larger refactorings, e.g. "Undo Copy class?", do?

>

Another question:
It seems like the undo is bound to the files/editors that are
modified by a command. Is it possible to associate a command
with an editor, even if the command does not change its contents?
Or, even better, is there some sort of project-global undo?

>

Background: I'm currently working on a taglib-editor that allows
editing of taglib descriptors. If I invoke an action in a specific
tag-class I want to edit the definition of, it would be nice if the
modifications to the TLD could be undone without switching to it.

>
>

Thanks,
Sascha

>
>

>
>

>
>


0
Comment actions Permalink

"Valentin Kipiatkov" <valentin@intellij.com> schrieb im Newsbeitrag
news:asfmg8$3mg$1@is.intellij.net...

We'll implement some API for this in Aurora. See
http://www.intellij.net/tracker/idea/viewSCR?publicId=7932


Ah, sounds great. Thanks.

Sascha


0

Please sign in to leave a comment.