//----------------------------------------------------------------------
//----------------------------------------------------------------------
//
//		---------------------
//		 Segment de donnees:
//		---------------------
//
//----------------------------------------------------------------------
//----------------------------------------------------------------------

//	Java	-- de base
//	
import		java.io.*;

//	Java	-- affichage graphique simple
//	
import		java.awt.*;
import		java.awt.event.*;

//----------------------------------------------------------------------
//----------------------------------------------------------------------

/**
 *	Exemple de classe destin&eacute;e &agrave; traduire
 *	une classe U.M.L. en lui adjoignant son interface graphique.
 */
public
class		Segment			extends		WindowAdapter
					implements	MissionExecutor
	{
// debut de classe
//----------------------------------------------------------------------

/**
 *	Informations qui constituent la clef d'acc&egrave;s au segment:
 */
int		noClient;

/**
 *	Autres informations du segment:
 */
String		nom;
String		prenom;
int		zipcode;
int		csp;

/**
 *	Acc&egrave;s ext&eacute;rieur aux donn&eacute;es:
 */

public
String		getNom			()
	{
	return	nom;
	}

public
void		setNom			(String p)
	{
	nom	= new String(p);
	}

public
String		getPrenom		()
	{
	return	nom;
	}

public
void		setPrenom		(String p)
	{
	nom	= new String(p);
	}

public
int		getZipcode		()
	{
	return	zipcode;
	}

public
void		setZipcode		(int p)
	{
	zipcode	= p;
	}

public
int		getCsp			()
	{
	return	csp;
	}

public
void		setCsp			(int p)
	{
	csp	= p;
	}

//----------------------------------------------------------------------

/**
 *	Elements de l'interface graphique.
 */
Panel		thePanelBoutons,
		thePanelClef,
		thePanelChamps;

/**
 *	Construction de l'interface graphique du segment,
 *	en construisant le segment lui-m&ecirc;me.
 */
		Segment			()
	{
	thePanelBoutons	= new Panel();
	thePanelBoutons.add(new MyButton(this, 1, "Create"));
	thePanelBoutons.add(new MyButton(this, 2, "Read"));
	thePanelBoutons.add(new MyButton(this, 3, "Update"));
	thePanelBoutons.add(new MyButton(this, 4, "Delete"));
	
	thePanelClef	= new Panel();
	thePanelClef	.setLayout(new GridLayout(0, 1));
	thePanelClef	.add	(new NomValeur	(10, 30, "noClient"));
	
	thePanelChamps 	= new Panel();
	thePanelChamps	.setLayout(new GridLayout(0, 1));
	thePanelChamps	.add	(new NomValeur	(10, 30, "nom"));
	thePanelChamps	.add	(new NomValeur	(10, 30, "prenom"));
	thePanelChamps	.add	(new NomValeur	(10, 30, "zipcode"));
	thePanelChamps	.add	(new NomValeur	(10, 30, "csp"));
	}

/**
 *	Il n'existe qu'une seule instance de 'Segment'.
 */
static
Segment		theSegment	= new Segment();

//----------------------------------------------------------------------
//	Code de gestion de la base de donnee.
//----------------------------------------------------------------------

/**
 *	Segment de donn&eacute;e 'Segment' -- fonction 'create'.
 */
void		create			()
	{
	System.out.println("create...");
	}

/**
 *	Segment de donn&eacute;e 'Segment' -- fonction 'read'.
 */
void		read			()
	{
	System.out.println("read...");
	}

/**
 *	Segment de donn&eacute;e 'Segment' -- fonction 'update'.
 */
void		update			()
	{
	System.out.println("update...");
	}

/**
 *	Segment de donn&eacute;e 'Segment' -- fonction 'delete'.
 */
void		delete			()
	{
	System.out.println("delete...");
	}

/**
 *	Call-back offert &agrave; l'interface graphique.
 */
public
void		faireMission		(int mission)
	{
	/* */if	(mission == 1)	create();
	else if	(mission == 2)	read();
	else if	(mission == 3)	update();
	else if	(mission == 4)	delete();
	}

//----------------------------------------------------------------------
//	Procedure d'utilisation de l'interface graphique.
//----------------------------------------------------------------------

/**
 *	Point d'entr&eacuye;e de 'java' au test de 'Segment'.
 */
public
static
void		main			(String[] args)
	{
	// l'IHM est instancie au premier appel
	if	(theFrame == null)
		{
		theFrame = new Frame(" Test de la classe 'Segment': ");
		theFrame.add(theSegment.thePanelBoutons	, BorderLayout.NORTH);
		theFrame.add(theSegment.thePanelClef	, BorderLayout.CENTER);
		theFrame.add(theSegment.thePanelChamps	, BorderLayout.SOUTH);
		theFrame.addWindowListener(theSegment);
		theFrame.setSize(400, 400);
		theFrame.validate();
		ToSQL.examine(theFrame);
		}
	// l'IHM est affiche a chaque appel (par menu)
	theFrame.setVisible(true);
	}

static
Frame		theFrame		= null;

public
void		windowClosing		(WindowEvent evt)
	{
	// l'IHM est masque a chaque demande (de l'utilisateur)
	theFrame.setVisible(false);
	}

//----------------------------------------------------------------------
// fin de classe
	}

//----------------------------------------------------------------------
//----------------------------------------------------------------------
//----------------------------------------------------------------------
//----------------------------------------------------------------------

