Copy and Paste Facility!!! [message #186238] |
Mon, 04 July 2005 07:08 |
Eclipse User |
|
|
|
Originally posted by: gautamn.iitk.ac.in
I want to provide Cut/Copy and Paste facility in my editor. How can i do
that???
Regards,
Nitin.
|
|
|
Re: Copy and Paste Facility!!! [message #186277 is a reply to message #186238] |
Mon, 04 July 2005 17:27 |
Eclipse User |
|
|
|
Originally posted by: raswinkumar.datamirror.com
Create
copyAction extending selectionAction
in the init method,
setId(ActionFactory.PASTE.getId());
then in the run method
GroupRequest copyReq = new GroupRequest(Messages.REQ_COPY);
getSelectedObjects() will return editparts as one the elements.
using the editpart(s), call
editpart.getCommand(copyReq);
this will go to the ComponentPolicy and request the command,
there, return a copyCommand extends command
example,
public class CopyCommand extends Command
{
public void execute()
{
// copy here
// u can call the editor and getSelectedObjects() or something
}
}
once the copy action gets the required command, execute the command by
calling
execute(getCommand(copyReq));
for the action to appear in the menu,
in the ActionBarAdvisor,
....
menu.add(ActionFactory.COPY.getID());
this should work... but u may have to use
protected boolean calculateEnabled()
{
}
in the CopyCommand to choose when it is enabled and when its not...
tell me once you get it running
"Nitin Gautam" <gautamn@iitk.ac.in> wrote in message
news:eec9ebda7f4f744c2bcb8be56172395f$1@www.eclipse.org...
>
> I want to provide Cut/Copy and Paste facility in my editor. How can i do
> that???
> Regards,
> Nitin.
>
|
|
|
Powered by
FUDForum. Page generated in 0.03125 seconds