- /* 
-  * MainPanel.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.*; 
- import reservation.system.functions.*; 
-   
- import javax.swing.*; 
- import javax.swing.filechooser.*; 
- import java.awt.Dimension; 
- import java.awt.event.*; 
- import java.io.*; 
-   
- /** 
-  * Create the object MainPanel. It define the first window where the user can chose the command to execute and that displays the result of the command. 
-  * @author Texier Mathieu and Frederic Bidon 
-  */ 
- public class MainPanel extends Panels { 
-      
-     /** Creates new form MainPanel */ 
-     public MainPanel () { 
-     } 
-      
-     /** 
-      * Constructor of this class. Do all the instance for create the graphical window. 
-      * @param mainDlg Parent object 
-      */ 
-     public MainPanel (final CustomDialog mainDlg) { 
-          
-         actionLabel.setText ("Action"); 
-         add (actionLabel); 
-          
-             } 
-         }); 
-         add (actionComboBox); 
-          
-         resultTextArea.setEditable (false); 
-         jScrollPane1.setViewportView (resultTextArea); 
-         add (jScrollPane1); 
-         init (); 
-     } 
-      
-     /** 
-      * Determine the command chosen by the user to create the apropriate window. 
-      */ 
-     private void Action (- CustomDialog mainDlg ) {
 
-         int nAction = actionComboBox.getSelectedIndex (); 
-         String-  retValue  = "Not executed \n";
 
-         ExampleFileFilter filter; 
-         Functions action; 
-          
-         switch (nAction) { 
-             case CustomDialog.STORE: 
-                 retValue = Store (); 
-                 break; 
-                  
-             case CustomDialog.READ_COMMAND: 
-                 retValue = ReadComand (); 
-                 break; 
-                  
-             case CustomDialog.RELOAD: 
-                 retValue = Reload (); 
-                 break; 
-                  
-             case CustomDialog.CREATE: 
-             case CustomDialog.RESERVE: 
-             case CustomDialog.CANCEL: 
-             case CustomDialog.SELECT: 
-             case CustomDialog.FLIGHTS: 
-                 CustomDialog dlg  = new-  CustomDialog  (- mainDlg,  true- ,  (String)-  actionComboBox. getSelectedItem ()- ,nAction );
-                 dlg.process (); 
-                 retValue = dlg.getRetValue (); 
-                 break; 
-             default: 
-                 CustomDialog. alert (new Exception ("Wrong slot value."));
-         } 
-         init (); 
-         resultTextArea.append (retValue); 
-     } 
-      
-     /** 
-      * Open a file selector dialog and read interprete the Request Comand Message that are contained 
-      * @return the appropriate result 
-      */     
-     static public String-  ReadComand  () {
 
-         ExampleFileFilter filter = new ExampleFileFilter (); 
-         filter.addExtension ("rcm"); 
-         filter.setDescription ("request command message"); 
-         chooser.setFileFilter (filter); 
-         if(- chooser. showOpenDialog (null) == JFileChooser- . APPROVE_OPTION) {
 
-             File-  file  =-  chooser. getSelectedFile ();
 
-             try { 
-                 Command mode = new Command (in,Mode.QUIET); 
-                 mode.process (); 
-                 return "File Loaded"; 
-         } 
-         return "Read command failed"; 
-     } 
-      
-     /** 
-      * Open a file selector dialog and deserialize the containing Flight System 
-      * @return the appropriate result 
-      */     
-     static public String-  Reload  () {
 
-         Functions action = new Reload (); 
-         ExampleFileFilter filter = new ExampleFileFilter (); 
-         filter.addExtension ("out"); 
-         filter.setDescription ("*.out"); 
-         chooser.setFileFilter (filter); 
-         if(- chooser. showOpenDialog (null) == JFileChooser- . APPROVE_OPTION) {
 
-             File-  datafile  =-  chooser. getSelectedFile ();
 
-             fileName[0] = datafile.getAbsolutePath (); 
-             try { 
-                 return action.execute (fileName) + "\n"; 
-             }catch (Exception-  e ) {- CustomDialog. alert (- e );}
 
-         } 
-         return " Reload Failed"; 
-     } 
-      
-     /** 
-      * Open a file selector dialog and store the serialzed Flight System 
-      * @return the appropriate result 
-      */     
-     static public String-  Store  () {
 
-         Functions action = new Store (); 
-         ExampleFileFilter filter = new ExampleFileFilter (); 
-         filter.addExtension ("out"); 
-         filter.setDescription ("*.out"); 
-         chooser.setFileFilter (filter); 
-         if(- chooser. showSaveDialog (null) == JFileChooser- . APPROVE_OPTION) {
 
-             File-  datafile  =-  chooser. getSelectedFile ();
 
-             fileName[0] = datafile.getAbsolutePath (); 
-             try { 
-                 return action.execute (fileName) + "\n"; 
-             }catch (Exception-  e ) {- CustomDialog. alert (- e );}
 
-         } 
-         return "Store failed"; 
-     } 
-     /** 
-      * Causes this container to lay out its components. 
-      */ 
-     public void doLayout () { 
-         actionLabel.setBounds (30, 10, 80, 20); 
-         actionComboBox.setBounds (100, 10, 110, 20); 
-         jScrollPane1.setBounds (20, 40, 450, 90); 
-     } 
-      
-     /** 
-      * 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. 
-      */ 
-     } 
-      
-     /** 
-      * Initialize the number of the field and fill them with default values. 
-      * Dispaly the label of the Window. 
-      */ 
-     public void init () { 
-         actionComboBox.removeAllItems (); 
-         try { 
-             actionComboBox.insertItemAt ("Reload", CustomDialog.RELOAD); 
-             actionComboBox.insertItemAt ("Read command", CustomDialog.READ_COMMAND); 
-             actionComboBox.insertItemAt ("Create", CustomDialog.CREATE); 
-             if (fs.getFlightList ().length > 0) { 
-                 actionComboBox.insertItemAt ("Store", CustomDialog.STORE); 
-                 actionComboBox.insertItemAt ("Reserve", CustomDialog.RESERVE); 
-                 actionComboBox.insertItemAt ("Flights", CustomDialog.FLIGHTS); 
-                 if (fs.getBookingList ().length > 0) { 
-                     actionComboBox.insertItemAt ("Cancel", CustomDialog.CANCEL); 
-                     actionComboBox.insertItemAt ("Select", CustomDialog.SELECT); 
-                 } 
-             } 
-         } 
-         catch (Exception-  e ) {- CustomDialog. alert (- e );}
 
-     } 
-      
-     /** 
-      * Proceed the execution of the action 
-      * @return the result of the request. 
-      * @param unUsed Not used 
-      * @throws Exception if the command is not executed. 
-      */ 
-         return ""; 
-     } 
-      
- } 
-