Add a toggle action to figure and communicate it to model via CommandStack [message #158565] |
Thu, 18 November 2004 15:44  |
Eclipse User |
|
|
|
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 #158860 is a reply to message #158837] |
Fri, 19 November 2004 14:00   |
Eclipse User |
|
|
|
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 11:25   |
Eclipse User |
|
|
|
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 #209725 is a reply to message #209245] |
Sat, 18 February 2006 22:44  |
Eclipse User |
|
|
|
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.
|
|
|
Powered by
FUDForum. Page generated in 0.02916 seconds