package transformation.associationtags.buttonlisteners;

import transformation.associationtags.AssociationTag;
import transformation.associationtags.AssociationTagWindow;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;

import javax.swing.JFrame;

public class EditButtonListener implements ActionListener {
	
	AssociationTag tag;
	List<AssociationTag> tags;
	AssociationTagWindow window;
	JFrame frame;
	
	public EditButtonListener(JFrame frame, AssociationTag tag, List<AssociationTag> tags, AssociationTagWindow window) {
				
		this.frame = frame;
		this.tag = tag;
		this.tags = tags;
		this.window = window;
		
	}

	/**
	 * Opens the association tag editing form
	 */
	public void actionPerformed(ActionEvent e) {
		
		this.frame.dispose();
		this.window.editTag(tag.getAction(), tag.getUser(), tag.getRole(),
								tags.indexOf(tag));
		
	}

}
