1 | /**
|
---|
2 | * BrowserApplet.java
|
---|
3 | * Copyright (C) 2010 New Zealand Digital Library, http://expeditee.org
|
---|
4 | *
|
---|
5 | * This program is free software: you can redistribute it and/or modify
|
---|
6 | * it under the terms of the GNU General Public License as published by
|
---|
7 | * the Free Software Foundation, either version 3 of the License, or
|
---|
8 | * (at your option) any later version.
|
---|
9 | *
|
---|
10 | * This program is distributed in the hope that it will be useful,
|
---|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
13 | * GNU General Public License for more details.
|
---|
14 | *
|
---|
15 | * You should have received a copy of the GNU General Public License
|
---|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
---|
17 | */
|
---|
18 |
|
---|
19 | package org.expeditee.gui;
|
---|
20 |
|
---|
21 | import java.io.File;
|
---|
22 |
|
---|
23 |
|
---|
24 |
|
---|
25 | import java.awt.*;
|
---|
26 | import java.awt.event.ActionEvent;
|
---|
27 | import java.awt.event.ActionListener;
|
---|
28 | import javax.swing.*;
|
---|
29 |
|
---|
30 | public class BrowserApplet extends JApplet implements ActionListener
|
---|
31 | {
|
---|
32 |
|
---|
33 | // point of entry for applet
|
---|
34 | public void init()
|
---|
35 | {
|
---|
36 |
|
---|
37 | // Check if the user has agreed to the requested security settings
|
---|
38 | try {
|
---|
39 | // Work-around to reduce number of
|
---|
40 | // 'Could not lock user prefs' error messages.
|
---|
41 | // Thanks to Walter Schatz from the java forums.
|
---|
42 | System.setProperty("java.util.prefs.syncInterval","2000000");
|
---|
43 | }
|
---|
44 | catch (Exception exception) {
|
---|
45 | getContentPane().add(new JLabel("Expeditee Applet deactivated", JLabel.CENTER));
|
---|
46 | return;
|
---|
47 | }
|
---|
48 |
|
---|
49 | // Ensure platform specific LAF
|
---|
50 | try {
|
---|
51 | UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
|
---|
52 | }
|
---|
53 | catch (Exception exception) {
|
---|
54 | exception.printStackTrace();
|
---|
55 | }
|
---|
56 |
|
---|
57 | // If there is username parameter passed in, use that
|
---|
58 |
|
---|
59 | String java_args = this.getParameter("java_arguments");
|
---|
60 | String testarg = this.getParameter("testarg");
|
---|
61 |
|
---|
62 | /*
|
---|
63 | String expeditee_home = System.getProperty("expeditee.home");
|
---|
64 | if (expeditee_home == null) {
|
---|
65 | expeditee_home = System.getProperty("user.home") + File.separator + "expeditee";
|
---|
66 | System.setProperty("expeditee.home",expeditee_home);
|
---|
67 | }
|
---|
68 | */
|
---|
69 |
|
---|
70 | String expeditee_home = this.getParameter("expeditee.home");
|
---|
71 |
|
---|
72 | if (expeditee_home == null) {
|
---|
73 | expeditee_home = System.getProperty("user.home") + File.separator + "expeditee";
|
---|
74 | }
|
---|
75 |
|
---|
76 | System.setProperty("expeditee.home",expeditee_home);
|
---|
77 |
|
---|
78 |
|
---|
79 | // Create a button for the user to press to open the main Expeditee frame
|
---|
80 | JButton launch_button = new JButton("Launch Expeditee ... : " + java_args + ", " + testarg);
|
---|
81 | launch_button.addActionListener(this);
|
---|
82 | getContentPane().add(launch_button);
|
---|
83 | }
|
---|
84 |
|
---|
85 |
|
---|
86 | public void start()
|
---|
87 | {
|
---|
88 | System.err.println("Applet start() called");
|
---|
89 | }
|
---|
90 |
|
---|
91 |
|
---|
92 | public void stop()
|
---|
93 | {
|
---|
94 | System.err.println("Applet stop() called");
|
---|
95 | }
|
---|
96 |
|
---|
97 |
|
---|
98 | public void destroy()
|
---|
99 | {
|
---|
100 | System.err.println("Applet destroy() called");
|
---|
101 | Browser._theBrowser.exit();
|
---|
102 | Browser._theBrowser = null;
|
---|
103 | System.err.println("Expeditee exited.");
|
---|
104 | }
|
---|
105 |
|
---|
106 |
|
---|
107 | public void actionPerformed(ActionEvent e)
|
---|
108 | {
|
---|
109 | if (Browser._theBrowser==null) {
|
---|
110 | Browser.main(null);
|
---|
111 | }
|
---|
112 | else {
|
---|
113 | // call set visible??
|
---|
114 | }
|
---|
115 | }
|
---|
116 |
|
---|
117 | /*
|
---|
118 | public static void main(String[] args) {
|
---|
119 |
|
---|
120 | }
|
---|
121 | */
|
---|
122 |
|
---|
123 |
|
---|
124 | }
|
---|