1 /*
2  *  (C) 2001 by Argonne National Laboratory
3  *      See COPYRIGHT in top-level directory.
4  */
5 
6 /*
7  *  @author  Anthony Chan
8  */
9 
10 package viewer.first;
11 
12 import java.awt.event.ActionEvent;
13 import java.awt.event.ActionListener;
14 import javax.swing.JMenu;
15 import javax.swing.JMenuBar;
16 import javax.swing.JMenuItem;
17 import javax.swing.border.EtchedBorder;
18 
19 import viewer.common.TopWindow;
20 
21 public class FirstMenuBar extends JMenuBar
22 {
23     private static final long      serialVersionUID = 14200L;
24 
25     private        boolean         isApplet;
26     private        FirstPanel      first_panel;
27 
28     private        JMenuItem       file_select_item;
29     private        JMenuItem       file_convert_item;
30     private        JMenuItem       file_close_item;
31     private        JMenuItem       file_exit_item;
32     private        JMenuItem       show_legend_item;
33     private        JMenuItem       show_timeline_item;
34     private        JMenuItem       edit_prefer_item;
35     private        JMenuItem       help_manual_item;
36     private        JMenuItem       help_faq_item;
37     private        JMenuItem       help_about_item;
38 
FirstMenuBar( boolean isTopApplet, FirstPanel in_panel )39     public FirstMenuBar( boolean isTopApplet, FirstPanel in_panel )
40     {
41         super();
42         super.setBorder( new EtchedBorder() );
43 
44         isApplet       = isTopApplet;
45         first_panel    = in_panel;
46 
47         JMenu      menu, submenu;
48             menu = new JMenu( "File" );
49                 file_select_item = new JMenuItem( "Select ..." );
50                 file_select_item.addActionListener( new ActionListener() {
51                     public void actionPerformed( ActionEvent evt ) {
52                         first_panel.getLogFileSelectButton().doClick();
53                     }
54                 } );
55             menu.add( file_select_item );
56                 file_convert_item = new JMenuItem( "Convert ..." );
57                 file_convert_item.addActionListener( new ActionListener() {
58                     public void actionPerformed( ActionEvent evt ) {
59                         first_panel.getLogFileConvertButton().doClick();
60                     }
61                 } );
62             menu.add( file_convert_item );
63                 file_close_item  = new JMenuItem( "Close" );
64                 file_close_item.addActionListener( new ActionListener() {
65                     public void actionPerformed( ActionEvent evt ) {
66                         first_panel.getLogFileCloseButton().doClick();
67                     }
68                 } );
69             menu.add( file_close_item );
70             menu.addSeparator();
71                 file_exit_item   = new JMenuItem( "Exit" );
72                 file_exit_item.addActionListener( new ActionListener() {
73                     public void actionPerformed( ActionEvent evt ) {
74                         if ( isApplet )
75                             TopWindow.Legend.disposeAll();
76                         else
77                             TopWindow.First.disposeAll();
78                     }
79                 } );
80             menu.add( file_exit_item );
81         super.add( menu );
82 
83             menu = new JMenu( "Edit" );
84                 edit_prefer_item = new JMenuItem( "Preferences ..." );
85                 edit_prefer_item.addActionListener( new ActionListener() {
86                     public void actionPerformed( ActionEvent evt ) {
87                         first_panel.getEditPreferenceButton().doClick();
88                     }
89                 } );
90             menu.add( edit_prefer_item );
91 
92         super.add( menu );
93 
94             menu = new JMenu( "View" );
95                 submenu = new JMenu( "Reload" );
96                     show_legend_item = new JMenuItem( "Legend window" );
97                     show_legend_item.addActionListener( new ActionListener() {
98                         public void actionPerformed( ActionEvent evt ) {
99                             first_panel.getShowLegendButton().doClick();
100                         }
101                     } );
102                 submenu.add( show_legend_item );
103                     show_timeline_item = new JMenuItem( "Timeline window" );
104                     show_timeline_item.addActionListener( new ActionListener() {
105                         public void actionPerformed( ActionEvent evt ) {
106                             first_panel.getShowTimelineButton().doClick();
107                         }
108                     } );
109                 submenu.add( show_timeline_item );
110             menu.add( submenu );
111         super.add( menu );
112 
113             menu = new JMenu( "Help" );
114                 help_manual_item = new JMenuItem( "Manual" );
115                 help_manual_item.addActionListener( new ActionListener() {
116                     public void actionPerformed( ActionEvent evt ) {
117                         first_panel.getHelpManualButton().doClick();
118                     }
119                 } );
120             menu.add( help_manual_item );
121                 help_faq_item = new JMenuItem( "FAQ" );
122                 help_faq_item.addActionListener( new ActionListener() {
123                     public void actionPerformed( ActionEvent evt ) {
124                         first_panel.getHelpFAQsButton().doClick();
125                     }
126                 } );
127             menu.add( help_faq_item );
128                 help_about_item = new JMenuItem( "About" );
129                 help_about_item.addActionListener( new ActionListener() {
130                     public void actionPerformed( ActionEvent evt ) {
131                         first_panel.getHelpAboutButton().doClick();
132                     }
133                 } );
134             menu.add( help_about_item );
135         super.add( menu );
136         // super.setAlignmentX( Component.LEFT_ALIGNMENT );
137     }
138 }
139