Skip to main content



      Home
Home » Eclipse Projects » GEF » Copy,Paste Facility!!!
Copy,Paste Facility!!! [message #194692] Mon, 05 September 2005 00:19 Go to next message
Eclipse UserFriend
Originally posted by: gautamn.iitk.ac.in

Hi,
i am implementing copy/paste facility in my editor...and i need some
help.
i have done all relevant steps for this...but its not working...actually
the problem is in getSelectedObjects()...its size is showing "0"...can
anybody mail me his code for above action....i am posting my action code.

public class CopyAction extends SelectionAction{

private List selectionList = null;
private Clipboard clipboard = null;
private DiagramView model=null;


/**
* @param part
*/
public CopyAction(IWorkbenchPart part) {
super(part);
// TODO Auto-generated constructor stub
}

public Clipboard getClipboard() {
if (clipboard == null) {
return null;
}
return clipboard;
}


protected void init() {
setId(ActionFactory.COPY.getId());
setText("Copy");
setToolTipText("Copy");
ISharedImages sharedImages =
PlatformUI.getWorkbench().getSharedImages();
setImageDescriptor(sharedImages.getImageDescriptor(
ISharedImages.IMG_TOOL_COPY));
setDisabledImageDescriptor(sharedImages.
getImageDescriptor(
ISharedImages.IMG_TOOL_COPY_DISABLED));
setEnabled(false);
}

public void run() {
getClipboard().setContents(selectionList);
}


/* (non-Javadoc)
* @see org.eclipse.gef.ui.actions.WorkbenchPartAction#calculateEnab led()
*/
protected boolean calculateEnabled() {
// TODO Auto-generated method stub
selectionList = getSelectedObjects();
System.out.println(">>>>*****@@@"+selectionList.size());
return true;
}


/**
* @param contents
*/
public void setCanvasModel(DiagramView contents) {
// TODO Auto-generated method stub
model=contents;

}


/**
* @param clipboard
*/
public void setClipboard(Clipboard clipboard) {
// TODO Auto-generated method stub
this.clipboard=clipboard;

}


}
Re: Copy,Paste Facility!!! [message #194750 is a reply to message #194692] Mon, 05 September 2005 12:02 Go to previous message
Eclipse UserFriend
Nitin Gautam wrote:
>
> Hi,
> i am implementing copy/paste facility in my editor...and i need some
> help.
> i have done all relevant steps for this...but its not working...actually
> the problem is in getSelectedObjects()...its size is showing "0"...can
> anybody mail me his code for above action

You can find working Copy and Paste code in the GMT/UMLX evolution of EDiagram,
but ... there the selection is consistently in model objects not EditParts
so that non-GEF selections can join in. See org.eclipse.gmt.umlx.editor.actions.CopyAction etc.

Regards

Ed Willink
Previous Topic:Creating a New Palette
Next Topic:Selection box customization.
Goto Forum:
  


Current Time: Sun Jul 06 08:03:09 EDT 2025

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

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

Back to the top