/*
* ReservePanel.java
* The package panels contains the different class executing the different windows of each function of the FlightSystem Reservation.
*/
package reservation.system.panels;
import reservation.system.functions.Reserve;
import reservation.CustomDialog;
import javax.swing.*;
import java.awt.event.*;
import java.awt.Dimension;
/**
* This class hold Reserve structure. This object allows to reserve to one flight one or many persons by calling the method <CODE>reserve</CODE> in {@link reservation.system.FlightSystem}.
* It use a GUI that contains a form with the several field to fill.
* @author Texier Mathieu and Frederic Bidon
*/
public class ReservePanel extends Panels {
/** Creates new form ReservePanel */
public ReservePanel () {
action = new Reserve ();
passengerLabel
= new JLabel ();
selectLabel.setText ("Select");
add (selectLabel);
flightSelect.
setMaximumSize (new Dimension (100,
20));
add (flightSelect);
passengerLabel.setText ("Passenger");
add (passengerLabel);
nameSelect.setEditable (true);
add (nameSelect);
addButton.setText ("Add");
add (addButton);
nameSelect.addItem ( nameSelect.getSelectedItem ());
nameSelect.getEditor ().setItem ("");
}
});
}
/**
* Initialize the number of the field and fill them with default values.
* Dispaly the label of the Window.
*/
public void init () {
try {
String [] retValue
= fs.
getFlightList ();
if (retValue != null) {
for (int i=0;i< retValue.length;i++) {
flightSelect.addItem (retValue[i]);
}
}
CustomDialog.alert (e);
}
}
/**
* Causes this container to lay out its components.
*/
public void doLayout () {
selectLabel.setBounds (20, 20, 40, 20);
flightSelect.setBounds (110, 20, 140, 20);
passengerLabel.setBounds (20, 60, 80, 20);
nameSelect.setBounds (110, 60, 70, 20);
addButton.setBounds (190, 60, 60, 20);
}
/**
* Set the size of the panel
* @return an instance of Dimension that represents the minimum size of this container.
*/
}
/**
* Set the size of the panel
* @return an instance of Dimension that represents the preferred size of this container.
*/
}
/**
* Proceed the execution of the action
* @return the result of the request.
* @param unUsed not used
* @throws Exception if the command is not executed.
*/
int itemNumber = nameSelect.getItemCount ();
arg
[0] = (String) flightSelect.
getSelectedItem ();
for (int i=0;i<itemNumber;i++) {
arg
[i
+1] = (String) nameSelect.
getItemAt (i
);
}
return action.execute (arg);
}
private JLabel passengerLabel
;
}