1   package org.wcb.gui.dialog;
2   
3   import org.wcb.gui.component.JXTitlePanel;
4   import org.wcb.gui.component.WaveButton;
5   import org.wcb.gui.forms.report.Faa8710Form;
6   import org.wcb.resources.MessageResourceRegister;
7   import org.wcb.resources.MessageKey;
8   import org.jdesktop.swingx.border.DropShadowBorder;
9   
10  import javax.swing.*;
11  import javax.swing.border.Border;
12  import javax.swing.border.CompoundBorder;
13  import java.awt.event.ActionListener;
14  import java.awt.event.ActionEvent;
15  import java.awt.*;
16  import java.net.URL;
17  
18  /**
19   * <small>
20   * <p/>
21   * Copyright (c)  2006  wbogaardt.
22   * This library is free software; you can redistribute it and/or
23   * modify it under the terms of the GNU Lesser General Public
24   * License as published by the Free Software Foundation; either
25   * version 2.1 of the License, or (at your option) any later version.
26   *
27   * This library is distributed in the hope that it will be useful,
28   * but WITHOUT ANY WARRANTY; without even the implied warranty of
29   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
30   * Lesser General Public License for more details.
31   *
32   * You should have received a copy of the GNU Lesser General Public
33   * License along with this library; if not, write to the Free Software
34   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
35   * <p/>
36   * $File:  $ <br>
37   * $Change:  $ submitted by $Author: wbogaardt $ at $DateTime: Aug 31, 2006 1:32:35 PM $ <br>
38   * </small>
39   *
40   * @author wbogaardt
41   *         Dialog box that displays the FAA8710 form panel and allows it to be printed.
42   */
43  
44  public class Faa8710Dialog extends JDialog implements ActionListener{
45  
46      private JButton okButton;
47      private Faa8710Form mainForm;
48      private JButton printButton;
49  
50      public Faa8710Dialog() {
51          setTitle("8710 Totals");
52          setModal(true);
53          setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
54          initComponents();
55      }
56  
57      public void addActionListener(ActionListener listener) {
58          okButton.addActionListener(listener);
59      }
60  
61      /**
62       * This calls and refreshes the main form which has a reference to the table model.
63       */
64      public void refresh() {
65          mainForm.refresh();
66      }
67  
68      /**
69       * Init the componets in the dialog.
70       */
71      private void initComponents() {
72          okButton = new WaveButton(MessageResourceRegister.getInstance().getValue(MessageKey.BUTTON_CLOSE));
73          URL printImageURL = Faa8710Dialog.class.getClassLoader().getResource("org/wcb/resources/gui/action_print.gif");
74          ImageIcon printIcon = new ImageIcon(printImageURL);
75          printButton = new WaveButton(printIcon);
76          printButton.addActionListener(this);
77  
78          getContentPane().setLayout(new BorderLayout());
79          getContentPane().setMinimumSize(new Dimension(800,400));
80  
81          JPanel mainPanel = new JXTitlePanel("FAA 8710 Totals", new Color(0x522aec));
82          Border shadow = new DropShadowBorder(Color.BLACK, 1, 10, .5f, 15, false, true, true, true);
83          mainPanel.setBorder(new CompoundBorder(shadow, mainPanel.getBorder()));
84          mainPanel.setLayout(new GridBagLayout());
85          GridBagConstraints gridBagConstraints;
86  
87          gridBagConstraints = new GridBagConstraints();
88          gridBagConstraints.gridx = 0;
89          gridBagConstraints.gridy = 0;
90          gridBagConstraints.anchor = GridBagConstraints.CENTER;
91          gridBagConstraints.gridwidth = 2;
92          mainForm = new Faa8710Form();
93          mainPanel.add(mainForm, gridBagConstraints);
94  
95          gridBagConstraints = new GridBagConstraints();
96          gridBagConstraints.gridx = 0;
97          gridBagConstraints.gridy = 1;
98          gridBagConstraints.anchor = GridBagConstraints.WEST;
99          mainPanel.add(okButton, gridBagConstraints);
100 
101         gridBagConstraints = new GridBagConstraints();
102         gridBagConstraints.gridx = 1;
103         gridBagConstraints.gridy = 1;
104         gridBagConstraints.anchor = GridBagConstraints.CENTER;
105         mainPanel.add(printButton, gridBagConstraints);
106 
107         getContentPane().add(mainPanel, BorderLayout.CENTER);
108     }
109 
110     public void actionPerformed(ActionEvent evt) {
111         Object src = evt.getSource();
112         if (src == printButton) {
113             mainForm.print();
114         }
115     }
116 }