//----------------------------BEGIN LICENSE----------------------------
/* 
 * Willow : the Open Source WorkFlow Project
 * Distributable under GNU LGPL license by gun.org
 *
 * Copyright (C) 2004-2010 huihoo.org 
 * Copyright (C) 2004-2010  ZosaTapo <dertyang@hotmail.com> 
 * 
 * ====================================================================
 * Project Homepage : http://www.huihoo.org/willow
 * Source Forge     : http://sourceforge.net/projects/huihoo
 * Mailing list     : willow@lists.sourceforge.net 
 */
//----------------------------END  LICENSE----------------------------
package org.huihoo.god4j.actions;

import java.awt.event.ActionEvent;
import java.awt.geom.Point2D;

import javax.swing.TransferHandler;

import org.huihoo.god4j.GOD4JFactory;
import org.huihoo.god4j.JGraphFrame;
import org.huihoo.god4j.jgraph.XPDLJGraph;
import org.huihoo.god4j.jgraph.XPDLJGraphMarqueeHandler;
import org.huihoo.god4j.jgraph.XPDLJGraphUI;

/**
 * @author Administrator
 *
 * To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */
public class PasteAt extends ActionBase
{
	public PasteAt()
	{
		super();
		setEnabled(false);
	}

	public void actionPerformed(ActionEvent event)
	{
		JGraphFrame frame = GOD4JFactory.getGOD4J().getControlPanel().getSelectedJGraph();
		if (frame == null)
		{
			return;
		}

		XPDLJGraph jGraph = frame.getJGraph();

		XPDLJGraphMarqueeHandler pemh = (XPDLJGraphMarqueeHandler) jGraph.getMarqueeHandler();
		Point2D pasteTo = pemh.getPopupPoint();
		XPDLJGraphUI peui = (XPDLJGraphUI) jGraph.getUI();
		peui.setInsertionPoint(pasteTo);
		
		TransferHandler.getPasteAction().actionPerformed(new ActionEvent(jGraph, event.getID(), event.getActionCommand()));
		GOD4JFactory.getGOD4J().setDirty(true);
		//peui.setInsertionPoint(null);
	}
}