/*
 *
 * Copyright (C)  5-sept-2003 Jean-Yves Beaujean 
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation; either version 2 of the License, or (at your option)
 * any later version.
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc.,  59
 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.

 * 
 */
package jxtray.swing;


import javax.swing.JTabbedPane;
import javax.swing.ImageIcon;

import jxtray.connection.JxtConnection;

import jxtray.Jxtray;
import jxtray.Messages;


public class JxtConnectionPanel extends JTabbedPane 
{

	public JxtConnectionPanel(String name)
	{
		    super();
			this.setName(name);
			init();
			this.setFont(Jxtray.getFont());
			this.revalidate();
	}
	
	/** Create and add the 3 panels */ 
	public void init()
	{
			try
			{
				JxtConnection con = (JxtConnection) Jxtray.getConnectionManager().get(this.getName());
				String catalog[] = con.getCatalogs();
				String schema[] = con.getSchemas(); 
				this.addTab("Structure",new ImageIcon(getClass().getResource("/images/structure.png")),new JxtStructurePanel(con,catalog,schema ),Jxtray.getLang("tooltip.structurepanel"));
		    	this.addTab("SQL",new ImageIcon(getClass().getResource("/images/sql.png")),new JxtSQLPanel(con,catalog,schema),Jxtray.getLang("tooltip.sqlpanel"));
		    	this.addTab("Dump datas",new ImageIcon(getClass().getResource("/images/dump.png")),new JxtDumpPanel(this.getName(),con,catalog,schema),Jxtray.getLang("tooltip.dumppanel"));
			}
			catch ( Exception e )
			{
				Messages.error("JxtConnectionPanel.constructor() : "+ e );
			}
	}
}
