| How could I invoke the undoable command? [message #210477] | 
Tue, 28 February 2006 11:25   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
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 17:42    | 
 
Eclipse User  | 
 | 
 | 
   | 
 
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 09:18   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
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> д
 |  
 |  
  | 
Powered by 
FUDForum. Page generated in 0.03787 seconds