Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Redo for Edit Tree Operation
Redo for Edit Tree Operation [message #464961] Wed, 21 March 2007 09:03 Go to next message
Swetha is currently offline SwethaFriend
Messages: 68
Registered: July 2009
Member
Hi,

I have written EditTreeOperation to handle the editing of tree item
on mouse double click.And I want to add Undo/Redo facility to this
operation...Here is the code I have written..Undo is working well but Redo
is not working ...Please tell me am I missing anything?

DoubleClick event Code: Where customerView is the instance of my customer
view

IUndoableOperation treeOperation = new EditTreeOperation();
workbench = customerView.getSite().getWorkbenchWindow().getWorkbench();
IOperationHistory operHistory = workbench.getOperationSupport()
.getOperationHistory();
IUndoContext myContext = workbench.getOperationSupport()
.getUndoContext();
treeOperation.addContext(myContext);
try
{
operHistory.execute(treeOperation, null, null);

} catch (Exception e1)
{
e1.printStackTrace();
}


Here is the EditTreeOperation code:


package com.sequenom.everest.ui.project;

import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.operations.AbstractOperation;
import org.eclipse.core.commands.operations.IUndoableOperation;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.swt.widgets.TreeItem;

/**
* An operation that makes tree item editable
*
*
*/
public class EditTreeOperation extends AbstractOperation implements
IUndoableOperation
{

TreeItem treeItem;

String text;


public EditTreeOperation()
{
super("Edit tree");

}

public IStatus execute(IProgressMonitor monitor, IAdaptable info)
throws ExecutionException
{

treeItem = customerView.tree
.getTree().getSelection()[0];
text = treeItem.getText().trim();

// handleEdit() contains the actual logic of editing of tree item

customerView.handleEdit();


return Status.OK_STATUS;
}


public IStatus redo(IProgressMonitor monitor, IAdaptable info)
throws ExecutionException
{
return undo(monitor, info);

}


public IStatus undo(IProgressMonitor monitor, IAdaptable info)
throws ExecutionException
{
treeItem.setText(text);
return Status.OK_STATUS;
}

}

Thnaks in advance,
Swetha
Re: Redo for Edit Tree Operation [message #464984 is a reply to message #464961] Wed, 21 March 2007 13:16 Go to previous message
Swetha is currently offline SwethaFriend
Messages: 68
Registered: July 2009
Member
Hi,

Can anyone help me please
Thanks,
Sujatha
Previous Topic:How the eclipse error messages are internationalized
Next Topic:React to closing of an editor
Goto Forum:
  


Current Time: Sun Oct 06 10:39:28 GMT 2024

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

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

Back to the top