1   package org.wcb.gui.dialog;
2   
3   import org.wcb.gui.forms.LogbookEntryForm;
4   import org.wcb.gui.forms.AircraftTableDisplayForm;
5   import org.wcb.gui.util.UIHelper;
6   import org.wcb.gui.component.JCloudPane;
7   import org.wcb.model.vo.hibernate.AircraftBO;
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 AircraftTableDisplayDialog extends JDialog implements ActionListener {
42  
43      private AircraftTableDisplayForm form;
44      private LogbookEntryForm parentCallingForm;
45  
46      public AircraftTableDisplayDialog() {
47          super.setTitle("Pilot's Log - Aircraft View");
48          super.setModal(true);
49          form = new AircraftTableDisplayForm(this, false);
50          initComponents();
51      }
52  
53      public AircraftTableDisplayDialog(JComponent parent) {
54          super.setTitle("Pilot's Log - Select Aircraft");
55          super.setModal(true);
56          if (parent instanceof LogbookEntryForm)
57          {
58              parentCallingForm = (LogbookEntryForm) parent;
59          }
60          form = new AircraftTableDisplayForm(this, true);
61          initComponents();
62      }
63  
64      /**
65       * Allows public access to refresh form table model.
66       */
67      public void refresh() {
68          form.refresh();
69      }
70  
71      /**
72       * Init the componets in the dialog.
73       */
74      private void initComponents() {
75          getContentPane().setLayout(new BorderLayout());
76          JCloudPane prettyUp = new JCloudPane();
77          prettyUp.add(form);
78          getContentPane().add(prettyUp, BorderLayout.CENTER);
79          pack();
80          UIHelper.centerDialogToScreen(this);
81      }
82  
83      public AircraftBO getAircraftSelected() {
84          return form.getSelectedRow();
85      }
86  
87      public void fireAircraftSelected() {
88          AircraftBO aircraft = form.getSelectedRow();
89          if (parentCallingForm != null) {
90              parentCallingForm.setAircraft(aircraft);
91          }
92          dispose();
93      }
94  
95      public void actionPerformed(ActionEvent evt) {
96          dispose();
97      }
98  
99  }