Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » How could I invoke the undoable command?
How could I invoke the undoable command? [message #210477] Tue, 28 February 2006 16:25 Go to next message
Eclipse UserFriend
Originally posted by: send60.eyou.com

Hi,everyone
I want implements the function like this:

when I change the Properties value in Property Sheet,I known
that it invoke the SetValueCommand in Class UndoablePropertySheetEntry to do
for the operation undoable.
Now ,I want to invoke the other Command not only invoke the SetValueCommand
when change the Properties value .
I mean that I want to do other operation when change the properties value
,and the whole operation can support the undo/redo function.....

this is the code int GEF Class UndoablePropertySheetEntry :

void valueChanged(UndoablePropertySheetEntry child, CompoundCommand command)
{
CompoundCommand cc = new CompoundCommand();
command.add(cc);

SetValueCommand setCommand;
for (int i = 0; i < getValues().length; i++) {
setCommand = new SetValueCommand(child.getDisplayName());
setCommand.setTarget(getPropertySource(getValues()[i]));
setCommand.setPropertyId(child.getDescriptor().getId());
setCommand.setPropertyValue(child.getValues()[i]);
cc.add(setCommand);
}

// inform our parent
if (getParent() != null)
((UndoablePropertySheetEntry)getParent()).valueChanged(this, command);
else {
//I am the root entry
stack.execute(command);
}
}

i think i should inherit the valueChanged method and add other command in
it,

But i find the UndoablePropertySheetEntry (in the package
org.eclipse.gef.ui.properties) is final class ,i cann't inherit
it ......

Is my idea right?
who could give me some help?
Thanks.

from kevin
Re: How could I invoke the undoable command? [message #210519 is a reply to message #210477] Tue, 28 February 2006 22:42 Go to previous messageGo to next message
Steven R. Shaw is currently offline Steven R. ShawFriend
Messages: 128
Registered: July 2009
Senior Member
Do you have a listener mechanism on your IPropertySource implementation that
fires property change events? If you take a look at LogicElement in
org.eclipse.gef.examples.logicdesigner.model, it has an interface to add a
PropertyChangeListener. If you add a listener for the property being
changed, you can optionally execute a new command is response.

-Steve


"Kevin" <send60@eyou.com> wrote in message
news:du1tls$bcg$1@utils.eclipse.org...
> Hi,everyone
> I want implements the function like this:
>
> when I change the Properties value in Property Sheet,I known
> that it invoke the SetValueCommand in Class UndoablePropertySheetEntry to
do
> for the operation undoable.
> Now ,I want to invoke the other Command not only invoke the
SetValueCommand
> when change the Properties value .
> I mean that I want to do other operation when change the properties value
> ,and the whole operation can support the undo/redo function.....
>
> this is the code int GEF Class UndoablePropertySheetEntry :
>
> void valueChanged(UndoablePropertySheetEntry child, CompoundCommand
command)
> {
> CompoundCommand cc = new CompoundCommand();
> command.add(cc);
>
> SetValueCommand setCommand;
> for (int i = 0; i < getValues().length; i++) {
> setCommand = new SetValueCommand(child.getDisplayName());
> setCommand.setTarget(getPropertySource(getValues()[i]));
> setCommand.setPropertyId(child.getDescriptor().getId());
> setCommand.setPropertyValue(child.getValues()[i]);
> cc.add(setCommand);
> }
>
> // inform our parent
> if (getParent() != null)
> ((UndoablePropertySheetEntry)getParent()).valueChanged(this, command);
> else {
> //I am the root entry
> stack.execute(command);
> }
> }
>
> i think i should inherit the valueChanged method and add other command in
> it,
>
> But i find the UndoablePropertySheetEntry (in the package
> org.eclipse.gef.ui.properties) is final class ,i cann't inherit
> it ......
>
> Is my idea right?
> who could give me some help?
> Thanks.
>
> from kevin
>
>
Re: How could I invoke the undoable command? [message #210632 is a reply to message #210519] Thu, 02 March 2006 14:18 Go to previous message
Eclipse UserFriend
Originally posted by: send60.eyou.com

Steven,Thank you very much.

In fact,I hava the listener which can get the inform when the property value
in Eclipse Property Page is changed.

But i want to know how to invoke the new command and add the new comand in
CommandStack,so that the command can support the undo /redo.....

Is there a way that i can run a Action(my be run some commands in it ) when
i change the property value in Eclipse Property Page ,like that I run the
Action in ContextMenu?

Thanks again!




"Steven Shaw" <steveshaw@ca.ibm.com> д
Previous Topic:Problem to draw a vertical Label
Next Topic:How to fetch GEF and build using command line?
Goto Forum:
  


Current Time: Thu Apr 18 17:41:49 GMT 2024

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

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

Back to the top