|
Re: How to share a commandstack between GEF editor and TextEditor in a multipleEditor? [message #154691 is a reply to message #154667] |
Thu, 21 October 2004 03:41 |
Eclipse User |
|
|
|
Originally posted by: none.us.ibm.com
You need to track document changes and capture them as GEF commands, or
track GEF commands and turn them into document changes.
It's unfortunate that there is not a command framework in the base Eclipse.
Please vote for:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=37716
"arfeifei" <arfeifei@gmail.com> wrote in message
news:cl6d19$8ke$1@eclipse.org...
> Hi
> I am trying to create a MultipleEditor follow the Redbook Workflow
> example.
> My MultipleEditor contains 2 Editor. one is GEF editor (same as example),
> another is a TextEditor(also use default wizard generated).
>
> But the problem is no matter how I changed in the TextEditor.The
> MultipleEditor only recongize GEF editor actions.make the changes to
Models.
> How to add TextEditor action hooks into GEF commandStack?. Because
> editDomain:addViewer will not accept the TextEditor.
>
> I searched the Platform newsgroup there is no such solution.
>
> //BOW
>
> arfeifei
>
>
|
|
|
Re: How to share a commandstack between GEF editor and TextEditor in a multipleEditor? [message #155003 is a reply to message #154691] |
Thu, 21 October 2004 16:01 |
Brian Fernandes Messages: 9 Registered: July 2009 |
Junior Member |
|
|
Hi Arfeifei,
I managed to to this for my editor.
I found the simplest technique was to implement a single delegating "stack",
so to speak.
This is a 3 step approach.
1)Modify GEF command stack for the GEF editor
2)Modfify DefaultUndoManager for the Text editor
3) Write a "unified" undo manager which will delegate undo / redo operations
to either editor.
Both #1 and #2 mentioned above have their own commands and command stacks.
The basic theory behind my implementation was to add a field to each of the
commands, called a command "stamp". This can be as simple as an incremental
counter - ie. When a command is added to a stack (for the first time) -
include the current counter value. Because of the counter, you know the
command ordering.
Now for #3. It's undo and redo methods will simply check the top of both
stacks (and the command stamps) to find the appropriate command to be undone
or redone.
Instead of extensive hacking I simply modified undo methods of #1 and #2 to
point to the undo method in #3. #3 makes the correct choice as described
above and will then call the original undo method in either #1 or #2.
Well, thats the theory. For instance, you might have to consider special
cases where a single action causes commands to be executed in both stacks.
Then an undo must cascade and undo both commands. Also, the text editor
obviously does no thav e"command" in the same sense of GEF commands.
Commands may be committed only after the "next" editing operation - or
editing operations may be clubbed into a single command. So you will have to
"commit" commands more frequently - like on page changes from text to GEF
editor.
I managed to get my implementation right after several iterations of dev and
bug fixing :)
Hope this helps - let me know how it turns out,
All the best,
Brian.
|
|
|
Re: How to share a commandstack between GEF editor and TextEditor in a multipleEditor? [message #155010 is a reply to message #155003] |
Thu, 21 October 2004 22:09 |
arfeifei Messages: 12 Registered: July 2009 |
Junior Member |
|
|
Hi Brian
Thanks
I will try!!!
arfeifei
"Brian Fernandes" <brian@genuitec.com> wrote in message
news:cl99hn$lhp$1@eclipse.org...
> Hi Arfeifei,
>
> I managed to to this for my editor.
>
> I found the simplest technique was to implement a single delegating
> "stack",
> so to speak.
>
> This is a 3 step approach.
> 1)Modify GEF command stack for the GEF editor
> 2)Modfify DefaultUndoManager for the Text editor
> 3) Write a "unified" undo manager which will delegate undo / redo
> operations
> to either editor.
>
> Both #1 and #2 mentioned above have their own commands and command stacks.
> The basic theory behind my implementation was to add a field to each of
> the
> commands, called a command "stamp". This can be as simple as an
> incremental
> counter - ie. When a command is added to a stack (for the first time) -
> include the current counter value. Because of the counter, you know the
> command ordering.
>
> Now for #3. It's undo and redo methods will simply check the top of both
> stacks (and the command stamps) to find the appropriate command to be
> undone
> or redone.
>
> Instead of extensive hacking I simply modified undo methods of #1 and #2
> to
> point to the undo method in #3. #3 makes the correct choice as described
> above and will then call the original undo method in either #1 or #2.
>
> Well, thats the theory. For instance, you might have to consider special
> cases where a single action causes commands to be executed in both stacks.
> Then an undo must cascade and undo both commands. Also, the text editor
> obviously does no thav e"command" in the same sense of GEF commands.
> Commands may be committed only after the "next" editing operation - or
> editing operations may be clubbed into a single command. So you will have
> to
> "commit" commands more frequently - like on page changes from text to GEF
> editor.
>
> I managed to get my implementation right after several iterations of dev
> and
> bug fixing :)
>
> Hope this helps - let me know how it turns out,
> All the best,
> Brian.
>
>
>
>
>
|
|
|
Re: How to share a commandstack between GEF editor and TextEditor in a multipleEditor? [message #155041 is a reply to message #155003] |
Fri, 22 October 2004 03:28 |
Eclipse User |
|
|
|
Originally posted by: none.us.ibm.com
Once concern I would have is that when GEF commands redo, they typically
replay the same action on the same instance of a given model object. But,
when text commands redo, they insert new text, which might then parsed and
result in the creation of a new (but identical) structural model object.
So, if you did something like this:
1) Insert "<P>this is a paragraph</P>" into your document
2) Select the Node for <P> and change the alignment to "right".
Where 1) is a text edit, and 2) is a GEF edit.
Undo, Undo will work, but Redo, Redo will fail (silently), because the
second Redo will be changing the alignment for a stale representation for
<P>
"Brian Fernandes" <brian@genuitec.com> wrote in message
news:cl99hn$lhp$1@eclipse.org...
> Hi Arfeifei,
>
> I managed to to this for my editor.
>
> I found the simplest technique was to implement a single delegating
"stack",
> so to speak.
>
> This is a 3 step approach.
> 1)Modify GEF command stack for the GEF editor
> 2)Modfify DefaultUndoManager for the Text editor
> 3) Write a "unified" undo manager which will delegate undo / redo
operations
> to either editor.
>
> Both #1 and #2 mentioned above have their own commands and command stacks.
> The basic theory behind my implementation was to add a field to each of
the
> commands, called a command "stamp". This can be as simple as an
incremental
> counter - ie. When a command is added to a stack (for the first time) -
> include the current counter value. Because of the counter, you know the
> command ordering.
>
> Now for #3. It's undo and redo methods will simply check the top of both
> stacks (and the command stamps) to find the appropriate command to be
undone
> or redone.
>
> Instead of extensive hacking I simply modified undo methods of #1 and #2
to
> point to the undo method in #3. #3 makes the correct choice as described
> above and will then call the original undo method in either #1 or #2.
>
> Well, thats the theory. For instance, you might have to consider special
> cases where a single action causes commands to be executed in both stacks.
> Then an undo must cascade and undo both commands. Also, the text editor
> obviously does no thav e"command" in the same sense of GEF commands.
> Commands may be committed only after the "next" editing operation - or
> editing operations may be clubbed into a single command. So you will have
to
> "commit" commands more frequently - like on page changes from text to GEF
> editor.
>
> I managed to get my implementation right after several iterations of dev
and
> bug fixing :)
>
> Hope this helps - let me know how it turns out,
> All the best,
> Brian.
>
>
>
>
>
|
|
|
|
Re: How to share a commandstack between GEF editor and TextEditor in a multipleEditor? [message #155380 is a reply to message #155210] |
Sun, 24 October 2004 22:48 |
Eclipse User |
|
|
|
Originally posted by: fei.tian.istark.com
Hi Brian & Randy
Well after I tried to constrcut GEF command in text editor. finally I give
it up.I directlly using TextEditor doSave method to save the document as
XML. Every time when flipping the pages between TextEditor and GEF editor
the active editor will load the modification model from File. May be this is
not a right approch to follow the MVC model. but at least it works :(((
Hope laterlly Redbook can provide an example how integrated GEF editor and
Text editor wihtin a multipleEditor.
Thanks both of your guys! You really give me some new ideas!
Arfeifei
"Brian Fernandes" <brian@genuitec.com> wrote in message
news:clbj6l$j9s$1@eclipse.org...
> Very valid point Randy, that slipped by me.
>
> I don't hit this in my editor because I have a cached map of my model
> objects. The text is parsed to get the "key" of a particular section of
> text
> (which corresponds to a GEF model) and the same model is retrieved from
> the
> cache if present.
>
> Arfeifei, you will certainly have to look out for this; maybe you'll come
> up
> with a better solution :)
>
> All the best,
> Brian.
>
>
>
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.04916 seconds