1   package org.wcb.gui.dialog;
2   
3   import org.wcb.gui.forms.AircraftEntryForm;
4   import org.wcb.gui.forms.AircraftTypeTableDisplayForm;
5   import org.wcb.gui.component.JCloudPane;
6   import org.wcb.gui.util.UIHelper;
7   import org.wcb.model.vo.hibernate.AircraftTypeBO;
8   
9   import javax.swing.*;
10  import java.awt.event.ActionListener;
11  import java.awt.event.ActionEvent;
12  import java.awt.*;
13  
14  /**
15   * <small>
16   * Copyright (c)  2006  wbogaardt.
17   * This library is free software; you can redistribute it and/or
18   * modify it under the terms of the GNU Lesser General Public
19   * License as published by the Free Software Foundation; either
20   * version 2.1 of the License, or (at your option) any later version.
21   *
22   * This library is distributed in the hope that it will be useful,
23   * but WITHOUT ANY WARRANTY; without even the implied warranty of
24   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
25   * Lesser General Public License for more details.
26   *
27   * You should have received a copy of the GNU Lesser General Public
28   * License along with this library; if not, write to the Free Software
29   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
30   * <p/>
31   * $File:  $ <br>
32   * $Change:  $ submitted by $Author: wbogaardt $ at $DateTime: Mar 30, 2006 11:11:59 AM $ <br>
33   * </small>
34   *
35   * @author wbogaardt
36   * @version 1
37   *          Date: Mar 30, 2006
38   *          Time: 11:11:59 AM
39   */
40  
41  public class AircraftTypeTableDisplayDialog extends JDialog implements ActionListener {
42  
43      private AircraftTypeTableDisplayForm form;
44      private AircraftEntryForm parentCallingForm;
45  
46      public AircraftTypeTableDisplayDialog() {
47          super.setTitle("Pilot's Log");
48          super.setModal(true);
49          form = new AircraftTypeTableDisplayForm(this, false);
50          initComponents();
51      }
52  
53      public AircraftTypeTableDisplayDialog(JComponent parent) {
54          super.setTitle("Pilot's Log");
55          super.setModal(true);
56          if (parent instanceof AircraftEntryForm)
57          {
58              parentCallingForm = (AircraftEntryForm) parent;
59          }
60          form = new AircraftTypeTableDisplayForm(this, true);
61          initComponents();
62      }
63  
64      /**
65       * Init the componets in the dialog.
66       */
67      private void initComponents() {
68          getContentPane().setLayout(new BorderLayout());
69          JCloudPane prettyUp = new JCloudPane();
70          prettyUp.add(form);
71          getContentPane().add(prettyUp, BorderLayout.CENTER);
72          pack();
73          UIHelper.centerDialogToScreen(this);
74      }
75  
76      public AircraftTypeBO getAircraftSelected() {
77          return form.getSelectedRow();
78      }
79  
80      public void fireAircraftSelected() {
81          AircraftTypeBO aircraft = form.getSelectedRow();
82          if (parentCallingForm != null) {
83              parentCallingForm.setAircraftType(aircraft);
84          }
85          dispose();
86      }
87  
88      public void actionPerformed(ActionEvent evt) {
89          dispose();
90      }
91  
92  }