Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Figure with Button, or manual Command execution
Figure with Button, or manual Command execution [message #189516] Wed, 27 July 2005 16:06 Go to next message
Eclipse UserFriend
Originally posted by: mom.mom.gmx.net

Hello,

i have added a Button to a Figure. When the User klicks on the Button I
want that a new Item is added to a List in the Model. (This is all not a
Problem, add Button, register Listener etc.)

Now, the question.
Because of the Command Pattern, I schould not change the Model directly
(While I would also loose undo functionality). So I need a Command to do
this for me. So the real problem is how to execute the Command?

The code looks like this :

void actionListener() {
Command cmd=new MyCommand( changedData );
commandStack.execute( cmd ); // Where to get the Commandstack ?
}

The Listener Function is in the EditPart (So the Base is
AbstractGraphicalEditPart). Is there a way to get the commandstack easily ?

*****
Alternative Solution (Gues it will at least end in the same problem) :

I found a older Posting here says I need to do :
> 1. Add a (Clickable) toggle to a figure.
> 2. Add changeListener to the toggle figure in the EditPart.
No Problem, done

> 3. In the changeListener on "pressed" event:
Here wo come

> -create a new request of type "TOGGLE";
I did :
Request req=new Request( myRoleID ); // myRoldID=new String("MYROLE");

> -call getCommand(request)
Command cmd=getCommand( req );

> -provide a policy that would generate a toggle command on this
> TOGGLE request.
So this is the stuff I was not able to do. Create a Policy is not a
Problem, but installEditPolicy needs as First Parameter a ROLE. But
which Role schould I use, it is a userdefinde role or ?

> 4. Toggle command will change the state of the model, which in
> turn fire a property change event, which will be received by
> the editPart and will refresh the figure. (ugh)
Here I'm not sure, after the stuff above will work I have only a
command. So I'm afraid i got the same Problem like in the first
Solution. How to get the CommandStack to execute the command.

regards Rainer
Re: Figure with Button, or manual Command execution [message #189551 is a reply to message #189516] Wed, 27 July 2005 17:27 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.unknown.com

"Rainer Weinhold" <mom.mom@gmx.net> wrote in message
news:dc8bcs$cnr$1@news.eclipse.org...
> Hello,
>
> i have added a Button to a Figure. When the User klicks on the Button I
> want that a new Item is added to a List in the Model. (This is all not a
> Problem, add Button, register Listener etc.)
>
> Now, the question.
> Because of the Command Pattern, I schould not change the Model directly
> (While I would also loose undo functionality). So I need a Command to do
> this for me. So the real problem is how to execute the Command?
>
> The code looks like this :
>
> void actionListener() {
> Command cmd=new MyCommand( changedData );
> commandStack.execute( cmd ); // Where to get the Commandstack ?
> }
>
> The Listener Function is in the EditPart (So the Base is
> AbstractGraphicalEditPart). Is there a way to get the commandstack easily
?

getViewer().getEditDomain().getCommandStack()

>
> *****
> Alternative Solution (Gues it will at least end in the same problem) :
>
> I found a older Posting here says I need to do :
> > 1. Add a (Clickable) toggle to a figure.
> > 2. Add changeListener to the toggle figure in the EditPart.
> No Problem, done
>
> > 3. In the changeListener on "pressed" event:
> Here wo come
>
> > -create a new request of type "TOGGLE";
> I did :
> Request req=new Request( myRoleID ); // myRoldID=new String("MYROLE");
>
> > -call getCommand(request)
> Command cmd=getCommand( req );
>
> > -provide a policy that would generate a toggle command on this
> > TOGGLE request.
> So this is the stuff I was not able to do. Create a Policy is not a
> Problem, but installEditPolicy needs as First Parameter a ROLE. But
> which Role schould I use, it is a userdefinde role or ?
>
> > 4. Toggle command will change the state of the model, which in
> > turn fire a property change event, which will be received by
> > the editPart and will refresh the figure. (ugh)
> Here I'm not sure, after the stuff above will work I have only a
> command. So I'm afraid i got the same Problem like in the first
> Solution. How to get the CommandStack to execute the command.
>
> regards Rainer
Re: Figure with Button, or manual Command execution [message #189606 is a reply to message #189551] Wed, 27 July 2005 21:33 Go to previous message
Eclipse UserFriend
Originally posted by: mom.mom.gmx.net

Pratik Shah schrieb:
> getViewer().getEditDomain().getCommandStack()

Thanks a lot. Don't know why I haven't seen it.

regards Rainer
Previous Topic:SnapFeedbackPolicy resource management bug?
Next Topic:Preview RootEditPart before displaying in main view
Goto Forum:
  


Current Time: Tue Dec 03 05:40:10 GMT 2024

Powered by FUDForum. Page generated in 0.03306 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top