Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Add a toggle action to figure and communicate it to model via CommandStack
Add a toggle action to figure and communicate it to model via CommandStack [message #158565] Thu, 18 November 2004 20:44 Go to next message
Eclipse UserFriend
Originally posted by: vladimir.bogus.com

Hello,

I need to be able to toggle the figure state by clicking on its hot spot via
CommandStack and persist the state information in my model. I think this is
doable using the following design, but would like to solicit an imput from
the gurus about whether this is a good approach.

1. Add a (Clickable) toggle to a figure.
2. Add changeListener to the toggle figure in the EditPart.
3. In the changeListener on "pressed" event:
-create a new request of type "TOGGLE";
-call getCommand(request)
-provide a policy that would generate a toggle command on this TOGGLE
request.
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)

This is a little convoluted, but it seems that it should be able to do the
job. Please let me know what you think. Thanks.

Vladimir
Re: Add a toggle action to figure and communicate it to model via CommandStack [message #158837 is a reply to message #158565] Fri, 19 November 2004 18:04 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

Sounds fine to me. Unless the "toggle" is something like expand/collapse,
which generally is not stored in the model and not undoable.

"Vladimir" <vladimir@bogus.com> wrote in message
news:cnj1ip$4sl$1@www.eclipse.org...
> Hello,
>
> I need to be able to toggle the figure state by clicking on its hot spot
via
> CommandStack and persist the state information in my model. I think this
is
> doable using the following design, but would like to solicit an imput from
> the gurus about whether this is a good approach.
>
> 1. Add a (Clickable) toggle to a figure.
> 2. Add changeListener to the toggle figure in the EditPart.
> 3. In the changeListener on "pressed" event:
> -create a new request of type "TOGGLE";
> -call getCommand(request)
> -provide a policy that would generate a toggle command on this TOGGLE
> request.
> 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)
>
> This is a little convoluted, but it seems that it should be able to do the
> job. Please let me know what you think. Thanks.
>
> Vladimir
>
>
Re: Add a toggle action to figure and communicate it to model via CommandStack [message #158860 is a reply to message #158837] Fri, 19 November 2004 19:00 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: vladimir.bogus.com

Thanks. Incidentally, I just finished coding and it works, with one minor
change - I have to listen to "selection" event, because "pressed" is fired
on both mouse up and mouse down.

Vladimir
"Randy Hudson" <none@us.ibm.com> wrote in message
news:cnlcj9$ina$1@www.eclipse.org...
> Sounds fine to me. Unless the "toggle" is something like expand/collapse,
> which generally is not stored in the model and not undoable.
>
> "Vladimir" <vladimir@bogus.com> wrote in message
> news:cnj1ip$4sl$1@www.eclipse.org...
> > Hello,
> >
> > I need to be able to toggle the figure state by clicking on its hot spot
> via
> > CommandStack and persist the state information in my model. I think this
> is
> > doable using the following design, but would like to solicit an imput
from
> > the gurus about whether this is a good approach.
> >
> > 1. Add a (Clickable) toggle to a figure.
> > 2. Add changeListener to the toggle figure in the EditPart.
> > 3. In the changeListener on "pressed" event:
> > -create a new request of type "TOGGLE";
> > -call getCommand(request)
> > -provide a policy that would generate a toggle command on this
TOGGLE
> > request.
> > 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)
> >
> > This is a little convoluted, but it seems that it should be able to do
the
> > job. Please let me know what you think. Thanks.
> >
> > Vladimir
> >
> >
>
>
Re: Add a toggle action to figure and communicate it to model via CommandStack [message #159206 is a reply to message #158860] Tue, 23 November 2004 16:25 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

Pressed is a state of the button UI, true/false. I think there is an
ActionListener just like other Button implementations.

"Vladimir" <vladimir@bogus.com> wrote in message
news:cnlfs4$om7$1@www.eclipse.org...
> Thanks. Incidentally, I just finished coding and it works, with one minor
> change - I have to listen to "selection" event, because "pressed" is fired
> on both mouse up and mouse down.
>
> Vladimir
> "Randy Hudson" <none@us.ibm.com> wrote in message
> news:cnlcj9$ina$1@www.eclipse.org...
> > Sounds fine to me. Unless the "toggle" is something like
expand/collapse,
> > which generally is not stored in the model and not undoable.
> >
> > "Vladimir" <vladimir@bogus.com> wrote in message
> > news:cnj1ip$4sl$1@www.eclipse.org...
> > > Hello,
> > >
> > > I need to be able to toggle the figure state by clicking on its hot
spot
> > via
> > > CommandStack and persist the state information in my model. I think
this
> > is
> > > doable using the following design, but would like to solicit an imput
> from
> > > the gurus about whether this is a good approach.
> > >
> > > 1. Add a (Clickable) toggle to a figure.
> > > 2. Add changeListener to the toggle figure in the EditPart.
> > > 3. In the changeListener on "pressed" event:
> > > -create a new request of type "TOGGLE";
> > > -call getCommand(request)
> > > -provide a policy that would generate a toggle command on this
> TOGGLE
> > > request.
> > > 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)
> > >
> > > This is a little convoluted, but it seems that it should be able to do
> the
> > > job. Please let me know what you think. Thanks.
> > >
> > > Vladimir
> > >
> > >
> >
> >
>
>
Re: Add a toggle action to figure and communicate it to model via CommandSt [message #209245 is a reply to message #159206] Mon, 13 February 2006 13:59 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: hplaas.gmx.de

Hi.

I actually have a similar problem:
I have a Figure called "state". To this Figure I add a checkBox and to the "stateEditPart I add the changelistener. Now i want to save the checkbox´s state(selected or not) in the Model.
But Vladimirs only works 80%: The getCommand method pushes the Command on the the Commandstack, but it does not execute, although the "canExecute" method returns "true".

And that´s my question: How does the Command will be executed. Do I need an actionClass? Then I´ve the problem to execute the "run" method, because i see no way to hook the action to the selectionTool. (or to call the run-method of the action within the editPart)

Thanks for replies
Heiko
Re: Add a toggle action to figure and communicate it to model via CommandSt [message #209725 is a reply to message #209245] Sun, 19 February 2006 03:44 Go to previous message
Eclipse UserFriend
Originally posted by: proyslim.gmail.com

Hi

I also had almost same problem as yours.

In my case, I solved this problem below.

------------------------------------------------------------ ------------
final CheckBox selector = new CheckBox();
selector.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
Request request = new Toggle();
Command cmd = getCommand(request);
if( cmd != null )
getViewer().getEditDomain().getCommandStack().execute(cmd);
}
});
------------------------------------------------------------ ------------

It would be good if my reply could help you.
Previous Topic:XYLayoutEditPolicy
Next Topic:How to find an object outside the visual area of a viewer
Goto Forum:
  


Current Time: Sat Apr 20 02:34:08 GMT 2024

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

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

Back to the top