/* $Id: ReadSearchListAction.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;

// TODO 位置が悪くないか？これは、このパッケージでなくて、search のメニューの関連のパッケージに入るのではないか？
class ReadSpreadSelectionListAction implements ActionListener {
	String SpreadSelectionListName = "";
	SetScopePanel callingSetScopePanel;

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

//			TODO 入力の形をチェックしてない。SpreadSelectionList および　名前、両方とも check。
//			名前が重複するときどうするか？ 
		SpreadSelectionListName = JOptionPane.showInputDialog("Input SpreadSelectionList name","");
		String selectionList = SpreadSelectionListManager.getInstance().getSpreadSelectionListString(SpreadSelectionListName);
		if (selectionList == null) {
			JOptionPane.showMessageDialog(null, "Spread Selection List " + SpreadSelectionListName + " does not exist");
			return;
		}
		this.callingSetScopePanel.getPageSelectField().setText(selectionList);
		this.callingSetScopePanel.getPageSelectField().repaint();
	}
}
