package action;

import java.awt.event.ActionEvent;
import java.util.HashMap;

import javax.swing.AbstractAction;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;

@SuppressWarnings("serial")
public class IdLoadAction extends AbstractAction {
/*
 * Button to load glycan sequences into input area from an Unicarb ID
 */
	
	JPanel jp;
	JTextField idTextField;
	JTextArea input;
	HashMap<String,String> unicarb;
	
	public IdLoadAction(JTextArea input, JTextField idTextField, HashMap<String,String> unicarb){
		this.input = input;
		this.idTextField = idTextField;
		this.unicarb = unicarb;
	}
	
	public void actionPerformed(ActionEvent arg0) {
		String id = idTextField.getText();
		String structureCT = "";
		if (unicarb.get(id) == null)
			JOptionPane.showMessageDialog(jp, "no entry for this Unicarb id", "Information", JOptionPane.WARNING_MESSAGE);
		else{
			structureCT = unicarb.get(id);
			input.setText(input.getText() + structureCT + "\n");
		}
		
	}

}
