/* $Id: ReadSpreadsBySpreadSelectionListAction.java 125 2011-03-09 09:49:51Z ohura $ */
package smart_gs.spread_selection;

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

import javax.swing.JOptionPane;

import smart_gs.logical.SpreadSelectionList;
import smart_gs.logical.SpreadSelectionListManager;

class ReadSpreadsBySpreadSelectionListAction implements ActionListener {
	String newSpreadSelectionListName = "";
	SetScopePanel callingSetScopePanel;

	public ReadSpreadsBySpreadSelectionListAction (String name, SetScopePanel setScopePanel) {
		this.newSpreadSelectionListName = name;
		this.callingSetScopePanel = setScopePanel;
		}
	
//	@Override
	public void actionPerformed(ActionEvent e) {
		ArrayList<SpreadSelectionList> SpreadSelectionLists = SpreadSelectionListManager.getInstance().getSpreadSelectionLists();

//			TODO 入力の形をチェックしてない。SpreadSelectionList および　名前、両方とも check。
//			名前が重複するときどうするか？
		newSpreadSelectionListName = JOptionPane.showInputDialog("Input SpreadSelectionList name",newSpreadSelectionListName);
		SpreadSelectionListManager.getInstance().addSpreadSelectionList(newSpreadSelectionListName,this.callingSetScopePanel.getPageSelectField().getText());
		Integer size = SpreadSelectionLists.size();
		Integer i = 0;
		while (i<size){
			System.out.println((SpreadSelectionLists.get(i)).toString());
			i++;
		}
	}

}
