/*
 * 作成日: 2005/11/06
 */
package asandatabasebrowser.action;
import java.awt.event.ActionEvent;
//import java.util.List;

import javax.swing.AbstractAction;
import javax.swing.JOptionPane;

import asandatabasebrowser.AsanDatabaseBrowser;
import asandatabasebrowser.model.VvDocument;
import asandatabasebrowser.view.DbTreeFrame;
import asandatabasebrowser.view.OptionDialog;



public class OptionAction extends AbstractAction {
	AsanDatabaseBrowser tools;
	public OptionAction(AsanDatabaseBrowser tools) {
		super("オプション(O) ...");
		putValue(MNEMONIC_KEY, new Integer('O'));
		putValue(SHORT_DESCRIPTION, "オプションの設定");
		putValue(LONG_DESCRIPTION, "オプションの設定");
		this.tools = tools;
	}

    public void actionPerformed(ActionEvent ev) {
		DbTreeFrame frame = tools.getTreeFrame();
    	OptionDialog dialog = new OptionDialog(frame);
		dialog.setMaxRecored(AsanDatabaseBrowser.theApp.doc.maxRecord);
//		dialog.setRollbackBeforeClose(AsanDatabaseBrowser.theApp.doc.rollbackBeforeClose);
//		dialog.setIgnoreTableNamePattern(AsanDatabaseBrowser.theApp.doc.ignoreTableNamePattern);
		dialog.setFontSize(AsanDatabaseBrowser.theApp.doc.fontSize);
    	dialog.pack();
    	dialog.setLocationRelativeTo(frame);
		dialog.setVisible(true);
		int ret = dialog.getReturnValue();
		System.out.println("ret="+ret);
		if (ret != JOptionPane.OK_OPTION) return;
		VvDocument doc = AsanDatabaseBrowser.theApp.doc;
		doc.maxRecord = dialog.getMaxRecord();
//		doc.rollbackBeforeClose = dialog.getRollbackBeforeClose();
//		doc.ignoreTableNamePattern = dialog.getIgnoreTableNamePattern();
		doc.fontSize = dialog.getFontSize();
		//doc.fontName = dialog.getChoosedFont().getFontName();
		doc.setModified(true);
		frame.updateMainFrame();
//    	List list = tools.getFrameList();
//    	for (int i=0; i<list.size(); i++) {
//    		list.get(i);
//    	}
    }
}

