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
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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 }