package com.abstratt.imageviewer;

import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.swt.dnd.Clipboard;
import org.eclipse.swt.dnd.ImageTransfer;
import org.eclipse.swt.dnd.TextTransfer;
import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IViewActionDelegate;
import org.eclipse.ui.IViewPart;

import com.abstratt.content.IContentProviderRegistry.IProviderDescription;

public class CopyToClipboardAction implements IViewActionDelegate {
	
	private GraphicalView view;

	public void init(IViewPart view) {
		this.view = (GraphicalView) view;
	}

	public void run(IAction action) {
		IProviderDescription providerDefinition = view.getContentProviderDescription();
		if (providerDefinition == null)
			return;
	    Image image = view.getViewer().getImage();
        ImageData imageData = image.getImageData();
	    ImageTransfer imageTransfer = ImageTransfer.getInstance();
        Clipboard clipboard = new Clipboard(Display.getCurrent());
        clipboard.setContents(new Object[]{imageData}, 
                new Transfer[]{imageTransfer});
	}

	public void selectionChanged(IAction action, ISelection selection) {
		// don't care
	}

}

@@ -204,50 +204,8 @@
 r;%0D%0A
-import org.eclipse.swt.dnd.TextTransfer;%0D%0A
 impo
@@ -230,32 +230,32 @@
 .dnd.Transfer;%0D%0A
+
 import org.eclip
@@ -447,86 +447,8 @@
 %0D%0A%0D%0A
-import com.abstratt.content.IContentProviderRegistry.IProviderDescription;%0D%0A%0D%0A
 publ
@@ -619,32 +619,32 @@
 w) view;%0D%0A%09%7D%0D%0A%0D%0A
+
 %09public void run
@@ -667,138 +667,8 @@
  %7B%0D%0A
-%09%09IProviderDescription providerDefinition = view.getContentProviderDescription();%0D%0A%09%09if (providerDefinition == null)%0D%0A%09%09%09return;%0D%0A
 %09   

allow copying to clipboard even if there is no source file