//----------------------------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/god4j
 * Source Forge     : http://sourceforge.net/projects/huihoo
 * Mailing list     : god4j@lists.sourceforge.net 
 */
//----------------------------END  LICENSE-----------------------------
package org.huihoo.god4j.actions;
import java.awt.event.ActionEvent;

import org.huihoo.god4j.GOD4JFactory;
import org.huihoo.god4j.JGraphFrame;
import org.huihoo.god4j.util.ToolUtils;
import org.huihoo.workflow.xpdl.WorkflowProcess;
/**
 * @author reic
 *
 * To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */
public class ShowGraph extends ActionBase
{
	private WorkflowProcess workflowProcess;
	
	public ShowGraph(WorkflowProcess workflowProcess)
	{
		this.workflowProcess = workflowProcess;
		setEnabled(true);
	}
	
	public void actionPerformed(ActionEvent e)
	{
		JGraphFrame frame  = GOD4JFactory.getGOD4J().getControlPanel().findJGraph(workflowProcess.getUUID());
		if (frame == null)
		{
			frame = ToolUtils.createJGraph( workflowProcess);
			GOD4JFactory.getGOD4J().getControlPanel().addJGraph(frame);
		}

    GOD4JFactory.getGOD4J().getControlPanel().setSelectedJGraph(frame);
	}
}