Skip to main content



      Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Undo/Redo facility
Undo/Redo facility [message #463534] Tue, 13 February 2007 07:27 Go to next message
Eclipse UserFriend
Originally posted by: sujatha.atc.tcs.co.in

Hi,

iam trying to use undo/redo facility provided by eclipse.

I have written an operation which extends abstarct operation and have
overridden
undo redo and execute methods.Then i have written a jface action .In the
run method i have added my operation to the operation history and also
added a context to the operation.when iam trying to execute the action in
he context menu,the call is going to constructor of operation but it is
not going to execute method .
do i need to call the execute method explicitly or will it be called
implicitly..?
are the above steps incorrect?do i need to use undoactionhandler or
redoactionhandler?
Re: Undo/Redo facility [message #463535 is a reply to message #463534] Tue, 13 February 2007 07:35 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: peter_ossipov.mail.ru

Hello.
For paste action, I have the following code in run method
PasteConnectionOperation pasteOperation = new
PasteConnectionOperation(someThingToPaste);
IOperationHistory history = (IOperationHistory)adaptable
.getAdapter(IOperationHistory.class);
// can be done this way getSite().getWorkbenchWindow().getWorkbench()
// .getOperationSupport().getOperationHistory()
try
{
IProgressMonitor monitor =
(IProgressMonitor)adaptable.getAdapter(IProgressMonitor.clas s);
history.execute(pasteOperation, monitor,
adaptable);
}
catch (ExecutionException e)
{
ExceptionHandler.handle(e);
}

it all works fine. Do you do the same?
SujathaKotte wrote:
>
> Hi,
>
> iam trying to use undo/redo facility provided by eclipse.
>
> I have written an operation which extends abstarct operation and have
> overridden
> undo redo and execute methods.Then i have written a jface action .In
> the run method i have added my operation to the operation history and
> also added a context to the operation.when iam trying to execute the
> action in he context menu,the call is going to constructor of
> operation but it is not going to execute method .
> do i need to call the execute method explicitly or will it be called
> implicitly..?
> are the above steps incorrect?do i need to use undoactionhandler or
> redoactionhandler?
>
>
Re: Undo/Redo facility [message #463536 is a reply to message #463535] Tue, 13 February 2007 07:42 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: sujatha.atc.tcs.co.in

hey iam not using adaptable classes.My code is as follows

IUndoableOperation treeOperation = new EditTreeOperation();
IWorkbench workbench = new
CustomerView().getSite().getWorkbenchWindow().getWorkbench() ;
IOperationHistory operHistory =
workbench.getOperationSupport().getOperationHistory();
IUndoContext myContext =
workbench.getOperationSupport().getUndoContext();

treeOperation.addContext(myContext);
operHistory.execute(treeOperation,null,null);

Br,
sujatha
Re: Undo/Redo facility [message #463538 is a reply to message #463536] Tue, 13 February 2007 07:45 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: peter_ossipov.mail.ru

hey! it is not a big deal. adaptable classes are not the point, though I
do not see why you are brave enough to pass two parameters as null. The
fist missing can be substituted by NullProgressMonitor, but the second
one has to be provided, as if I am not mistaken you have to pass an
adaptable that at least can adapt to Shell class.
SujathaKotte wrote:
>
> hey iam not using adaptable classes.My code is as follows
>
> IUndoableOperation treeOperation = new EditTreeOperation();
> IWorkbench workbench = new
> CustomerView().getSite().getWorkbenchWindow().getWorkbench() ;
> IOperationHistory operHistory =
> workbench.getOperationSupport().getOperationHistory();
> IUndoContext myContext =
> workbench.getOperationSupport().getUndoContext();
> treeOperation.addContext(myContext);
> operHistory.execute(treeOperation,null,null);
>
> Br,
> sujatha
>
>
>
>
Re: Undo/Redo facility [message #463649 is a reply to message #463535] Wed, 14 February 2007 01:26 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: sujatha.atc.tcs.co.in

hey i have tried with out null ,but its not working.

can u send me any links for sample snippet of a simple operation (actually
i am keen to know how the flow goes on)

BR,
Sujatha
Re: Undo/Redo facility [message #463655 is a reply to message #463649] Wed, 14 February 2007 03:25 Go to previous message
Eclipse UserFriend
Originally posted by: peter_ossipov.mail.ru

Hey, Sujatha!
Wazz up? Anyway, I do not see why your stuff is not working... Just a
guess... Try removing that line with adding context.
In addition, in your case I would debug and see what the operation
history is doing with your operation. Besides, why do not you have
try/catch block? are you throwing it in your method? just checking.
SujathaKotte wrote:
>
> hey i have tried with out null ,but its not working.
>
> can u send me any links for sample snippet of a simple operation
> (actually i am keen to know how the flow goes on)
>
> BR,
> Sujatha
>
Previous Topic:How to pass a parameter to a view
Next Topic:Text editor
Goto Forum:
  


Current Time: Wed Mar 19 16:49:34 EDT 2025

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

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

Back to the top