/*
#=============================================================================
#																			   
#			Copyright (c) 2009 Origin Enterprise Solution LTD.		   
#																			   
#=============================================================================
# File name: ShowMessageDialog.java
# File description: 										   	
#=============================================================================
#	Date		Name		    Action		Description of Change					   
#	2009-10-30	tyl  	创建			 显示信息					
#	2010-02-10	tyl  	Mod			信息前减少空格 			
#=============================================================================
 */

package cn.com.customization.util;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
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 ShowMessageDialog extends AbstractAIFDialog {

	private static final long	serialVersionUID	= 1L;
	private String				title				= "";
	private String				info1				= "";
	private String				info2				= "";

	public ShowMessageDialog(String title, String info1, String info2) {
		super(true);
		this.title = title;
		this.info1 = info1;
		this.info2 = info2;
		initUI();
	}

	public void initUI() {
		setPersistentDisplay(true);
		setOptimalDisplay(false);
		setTitle(title);
		JPanel parentPanel;
		JPanel iconPanel = new JPanel();
		JPanel itemInfoPanel1;
		JPanel itemInfoPanel2;
		parentPanel = new JPanel(new VerticalLayout(5, 2, 2, 2, 2));
		itemInfoPanel2 = new JPanel(new GridLayout(2, 1));
		itemInfoPanel1 = new JPanel(new PropertyLayout());

		URL url = this.getClass().getResource("image/info.png");
		JLabel iconLabel = new JLabel();
		iconLabel.setIcon(new ImageIcon(url));
		iconPanel.add(iconLabel);

		itemInfoPanel2.add(new JLabel(" " + info1));
		itemInfoPanel2.add(new JLabel(info2));

		itemInfoPanel1.add("1.1.left.center", iconPanel);
		itemInfoPanel1.add("1.2.left.center", itemInfoPanel2);

		JButton buttonYes = new JButton("确定");
		buttonYes.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				ShowMessageDialog.this.dispose();
			}
		});
		JPanel panelButton = new JPanel(new BorderLayout());
		panelButton.setSize(10, 20);
		panelButton.add(buttonYes, BorderLayout.CENTER);

		parentPanel.add("top.bin", new JLabel("  "));
		parentPanel.add("top.bind.left.top", itemInfoPanel1);
		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);
	}
}
