/*
#=======================================================================================================
#
#                   Copyright (c) 2007 Origin Enterprise Solution LTD.
#
#=======================================================================================================
# File description:  GetMessagePromptDialog.java
#=======================================================================================================
#	Date		Name		 Action	     Description of Change
#	2009-11-13	tyl  	创建		 消息提示窗体
#=======================================================================================================
 */
package cn.com.customization.util;

import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.URL;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;

import com.teamcenter.rac.aif.AbstractAIFDialog;
import com.teamcenter.rac.util.PropertyLayout;
import com.teamcenter.rac.util.VerticalLayout;

public class GetMessagePromptDialog extends AbstractAIFDialog {

	/**
	 * serialVersionUID:TODO（用一句话描述这个变量表示什么）
	 * @since Ver 1.1
	 */

	private static final long	serialVersionUID	= 1L;
	private String				title;
	private String				info;
	private String				info2;
	private int					value				= 1;

	/**
	 * Creates a new instance of PromptDialog.
	 */

	public GetMessagePromptDialog(String title, String info) {
		super(true);
		this.title = title;
		this.info = info;
	}

	public GetMessagePromptDialog(String title, String info, String info2) {
		super(true);
		this.title = title;
		this.info = info;
		this.info2 = info2;
	}

	// 返回决定：
	public int getValue() {
		setPersistentDisplay(true);
		setOptimalDisplay(false);
		setTitle(title);

		JPanel parentPanel;
		JPanel itemInfoPanel;
		parentPanel = new JPanel(new VerticalLayout(5, 2, 2, 2, 2));
		itemInfoPanel = new JPanel(new PropertyLayout());
		URL url = this.getClass().getResource("image/info.png");
		JLabel iconLabel = new JLabel();
		iconLabel.setIcon(new ImageIcon(url));

		itemInfoPanel.add("1.1.left.center", iconLabel);
		itemInfoPanel.add("1.2.left.center", new JLabel(info));
		itemInfoPanel.add("2.1.left.center", new JLabel("           "));
		itemInfoPanel.add("2.2.left.center", new JLabel(info2));
		JButton buttonYes = new JButton("是");
		buttonYes.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				value = 0;
				GetMessagePromptDialog.this.dispose();
			}
		});
		JButton buttonNo = new JButton("否");
		buttonNo.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				value = 1;
				GetMessagePromptDialog.this.dispose();
			}
		});
		JPanel panelButton = new JPanel(new FlowLayout());
		panelButton.add(buttonYes);
		panelButton.add(buttonNo);
		parentPanel.add("top.bin", new JLabel("  "));
		parentPanel.add("top.bind.left.top", itemInfoPanel);
		parentPanel.add("bottom.nobind.center.top", panelButton);
		getContentPane().add(parentPanel);
		pack();
		Dimension screen = getToolkit().getScreenSize(); // 得到屏幕尺寸
		setLocation((screen.width - getSize().width) / 2, (screen.height - getSize().height) / 2);
		setVisible(true);
		return value;
	}

}
