-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHelpMenu.java
executable file
·180 lines (158 loc) · 5.76 KB
/
HelpMenu.java
1
2
3
4
5
6
7
8
9
10
11
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
// HelpMenu.java implements the menu for help options in the applet.
//
//-------------------------------------------------------------------
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import java.net.URL;
import java.io.BufferedInputStream;
public class HelpMenu extends JMenu implements ActionListener
{
private imgViewer applet;
private JMenuItem dataAcqRequestItem;
private String glovisTitle;
private String glovisVersion;
// constructor
public HelpMenu(imgViewer applet, String title)
{
// call the parent constructor, setting the dialog to be modal
super(title);
setMnemonic(KeyEvent.VK_H);
// save the applet object
this.applet = applet;
this.glovisTitle = "USGS Global Visualization Viewer (GloVis)";
this.glovisVersion = "Version: 8.16";
// add the quick start selection
JMenuItem item = new JMenuItem("Quick Start Guide", KeyEvent.VK_Q);
item.addActionListener(this);
add(item);
// add the viewer help selection
item = new JMenuItem("User Guide", KeyEvent.VK_U);
item.addActionListener(this);
add(item);
// add the about browse selection
item = new JMenuItem("About Browse Images", KeyEvent.VK_B);
item.addActionListener(this);
add(item);
// add the GloVis Brochure selection
item = new JMenuItem("GloVis Brochure", KeyEvent.VK_L);
item.addActionListener(this);
add(item);
// add the about GloVis selection
item = new JMenuItem("About GloVis", KeyEvent.VK_G);
item.addActionListener(this);
add(item);
// divide between static menu options and sensor-specific
addSeparator();
// add the product info selection
item = new JMenuItem("Product Information", KeyEvent.VK_P);
item.addActionListener(this);
add(item);
// add the acquisition schedule selection
item = new JMenuItem("Data Acquisition Schedule", KeyEvent.VK_D);
item.addActionListener(this);
add(item);
// create the menu item for the data acquisition request menu item
// but don't add it to the menu since it is only visible for some
// sensors
dataAcqRequestItem = new JMenuItem("Data Acquisition Request",
KeyEvent.VK_R);
dataAcqRequestItem.addActionListener(this);
// item = new JMenuItem("Home", KeyEvent.VK_H);
// item.addActionListener(this);
// add(item);
// configure the menu for the current sensor
setSensor(applet.sensorMenu.getCurrentSensor());
}
// method to configure the menu for the current sensor
//----------------------------------------------------
public void setSensor(Sensor currentSensor)
{
if (currentSensor.dataAcqRequestURL != null)
{
// add the data request menu item
int insertLocation = 5;
insert(dataAcqRequestItem,insertLocation);
}
else
remove(dataAcqRequestItem);
}
// show "About GloVis" dialog
// --------------------------
public void aboutGloVis()
{
List<String> about = new ArrayList<String>();
about.add(this.glovisTitle);
about.add(this.glovisVersion);
JOptionPane.showMessageDialog(applet.getDialogContainer(),
about.toArray(), "About GloVis",
JOptionPane.INFORMATION_MESSAGE);
return;
}
// event handler for the menu selections
//--------------------------------------
public void actionPerformed(ActionEvent event)
{
String command = event.getActionCommand();
String page = null;
String targetWindow = null;
if (command.equals("Quick Start Guide"))
{
page = new String("../QuickStart.shtml");
targetWindow = new String("glovishelp");
}
else if (command.equals("User Guide"))
{
page = new String("../ImgViewerHelp.shtml");
targetWindow = new String("glovishelp");
}
else if (command.equals("About Browse Images"))
{
page = new String("../AboutBrowse.shtml");
targetWindow = new String("glovishelp");
}
else if (command.equals("GloVis Brochure"))
{
page = new String("http://pubs.usgs.gov/gip/137/");
targetWindow = new String("brochure");
}
else if (command.equals("About GloVis"))
{
aboutGloVis();
}
else if (command.equals("Product Information"))
{
page = applet.sensorMenu.getCurrentSensor().productInfoURL;
targetWindow = new String("_blank");
}
else if (command.equals("Data Acquisition Schedule"))
{
page = applet.sensorMenu.getCurrentSensor().acquisitionScheduleURL;
targetWindow = new String("_blank");
}
else if (command.equals("Data Acquisition Request"))
{
page = applet.sensorMenu.getCurrentSensor().dataAcqRequestURL;
targetWindow = new String("_blank");
}
else if (command.equals("Home"))
{
page = new String("../index.shtml");
targetWindow = new String("_blank");
}
if (page != null)
{
try
{
URL linkURL = new URL(applet.getCodeBase(),page);
applet.getAppletContext().showDocument(linkURL,targetWindow);
}
catch (Exception e){}
}
}
}