1   package org.wcb.gui.component;
2   
3   import org.wcb.gui.util.PrintUtilities;
4   import org.wcb.gui.LogbookFrame;
5   import org.wcb.model.vo.hibernate.Logbook;
6   
7   import javax.swing.*;
8   import java.net.URL;
9   import java.awt.event.ActionEvent;
10  import java.awt.event.ActionListener;
11  import java.awt.*;
12  
13  /**
14   * <small>
15   * Copyright (c)  2006  wbogaardt.
16   * This library is free software; you can redistribute it and/or
17   * modify it under the terms of the GNU Lesser General Public
18   * License as published by the Free Software Foundation; either
19   * version 2.1 of the License, or (at your option) any later version.
20   *
21   * This library is distributed in the hope that it will be useful,
22   * but WITHOUT ANY WARRANTY; without even the implied warranty of
23   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
24   * Lesser General Public License for more details.
25   *
26   * You should have received a copy of the GNU Lesser General Public
27   * License along with this library; if not, write to the Free Software
28   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
29   * <p/>
30   * $File:  $ <br>
31   * $Change:  $ submitted by $Author: wbogaardt $ at $DateTime: Apr 14, 2006 2:12:36 PM $ <br>
32   * </small>
33   *
34   * @author wbogaardt
35   * @version 1
36   *          Date: Apr 14, 2006
37   *          Time: 2:12:36 PM
38   */
39  
40  public class JPilotIconMenu extends JMenuBar implements ActionListener {
41      private JButton addEntry;
42      private JButton printButton;
43      private LogbookFrame frame;
44  
45      public JPilotIconMenu() {
46          initComponets();
47      }
48  
49      public JPilotIconMenu(LogbookFrame frameVO) {
50          this.frame = frameVO;
51          initComponets();
52      }
53  
54      private void initComponets() {
55          URL rptImageURL = JPilotMenu.class.getClassLoader().getResource("org/wcb/resources/gui/write_log.gif");
56          ImageIcon insertIcon = new ImageIcon(rptImageURL);
57          addEntry = new WaveButton(insertIcon);
58          addEntry.setToolTipText("Add new logbook entry.");
59          addEntry.addActionListener(this);
60          URL printImageURL = JPilotMenu.class.getClassLoader().getResource("org/wcb/resources/gui/action_print.gif");
61          ImageIcon printIcon = new ImageIcon(printImageURL);
62          printButton = new WaveButton(printIcon);
63          printButton.setToolTipText("Print entire logbook.");
64          printButton.addActionListener(this);
65          add(addEntry);
66          add(printButton);
67      }
68  
69      public void actionPerformed(ActionEvent evt) {
70          Object src = evt.getSource();
71          if (src == addEntry) {
72              CardLayout cl = (CardLayout) frame.getCardPanel().getLayout();
73              frame.setLogEntryForm(new Logbook());
74              cl.show(frame.getCardPanel(), LogbookFrame.LOGBOOK_ENTRY_VIEW);
75          }
76          if (src == printButton) {
77              PrintUtilities.printTable();
78          }
79      }
80  }