package transformation.associationtags.buttonlisteners;

import transformation.associationtags.AssociationTagWindow;

import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;

public class CancelButtonListener implements ActionListener {

	AssociationTagWindow window;
	
	public CancelButtonListener(AssociationTagWindow window) {
		this.window = window;
	}
	
	/**
	 * Closes the association tag adding form without making any changes
	 */
	public void actionPerformed(ActionEvent e) {
		Container container = ((JButton) e.getSource()).getParent();
		while (container.getClass() != JFrame.class) {
			container = container.getParent();
		}
		JFrame frame = (JFrame) container;
		frame.dispose();
		window.showTags();
	}

}
