1 package devisor2.grid.GUI.help;
2 
3 import javax.swing.*;
4 import javax.swing.event.*;
5 import javax.swing.text.html.*;
6 import java.awt.*;
7 import java.awt.event.*;
8 
9 import java.net.*;
10 import java.io.*;
11 
12 import devisor2.grid.options.*;
13 
14 /**
15  *  This class is just a simple container to display the online version of
16  *  the manual (which will be created by the tex2html tool. <br>
17  *  So far, no contextsensitivity has been added.
18  *
19  * @author Dominik Goeddeke (based on an implementation by Matthias Moeller)
20  * @version 0.9
21  */
22 public class HelpFrame extends JFrame
23 {
24     /**
25      *  reference to the ControlCenter
26      */
27     private ControlCenter cc;
28 
29     /**
30      *  the Constructor just initialises a new HelpFrame and connects it
31      *  to the html file of the manual
32      *
33      *  @param String filename the absolut path (or relative path from
34      *                         devisorhome) to the index.html file
35      *  @throws IOException if the specified file could not be loaded properly
36      */
HelpFrame(String filename)37     public HelpFrame(String filename)
38 	throws IOException
39     {
40 	// general stuff as usual
41 	cc = ControlCenter.getMyself ();
42 	// lay out GUI elements
43 	initComponents ();
44 	// Add HTML-file to be displayed
45 	jEditorPane1.setEditorKit(new HTMLEditorKit());
46 	jEditorPane1.setPage(filename);
47 	jEditorPane1.setBackground(Color.white);
48 	jEditorPane1.setForeground(Color.black);
49 	jEditorPane1.addHyperlinkListener(createHyperLinkListener());
50 	// all done
51 	pack ();
52     }
53 
54     /**
55      *  lays out GUI elements
56      */
initComponents()57     private void initComponents ()
58     {
59 	jPanel1 = new JPanel ();
60 	jButton1 = new JButton ();
61 	jScrollPane1 = new JScrollPane ();
62 	jEditorPane1 = new JEditorPane ();
63 	setTitle ((String)cc.rb.getObject("GUI_help_HelpFrame_frametitle"));
64 	jButton1.setText ((String)cc.rb.getObject("general_Ok"));
65 	jButton1.addActionListener (new java.awt.event.ActionListener () {
66 		public void actionPerformed (java.awt.event.ActionEvent evt) {
67 		    exitFrame ();
68 		}
69 	    });
70 	jPanel1.add (jButton1);
71 	getContentPane ().add (jPanel1, java.awt.BorderLayout.SOUTH);
72 	jEditorPane1.setContentType ("text/html");
73 	jEditorPane1.setEditable(false);
74 	jEditorPane1.setFont (new Font ("Default", 0, 12));
75 	jScrollPane1.setViewportView (jEditorPane1);
76 	getContentPane ().add (jScrollPane1, java.awt.BorderLayout.CENTER);
77     }
78 
79     /**
80      *  just hides the frame
81      */
exitFrame()82     private void exitFrame()
83     {
84 	this.hide();
85     }
86 
87     // attributes for quick reference to  GUI elements
88     private JPanel jPanel1;
89     private JButton jButton1;
90     private JScrollPane jScrollPane1;
91     private JEditorPane jEditorPane1;
92 
createHyperLinkListener()93     public HyperlinkListener createHyperLinkListener()
94     {
95 	return new HyperlinkListener()
96 	    {
97 		public void hyperlinkUpdate(HyperlinkEvent e)
98 		{
99 		    if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
100 			if (e instanceof HTMLFrameHyperlinkEvent) {
101 			    ((HTMLDocument)jEditorPane1.getDocument()).processHTMLFrameHyperlinkEvent((HTMLFrameHyperlinkEvent)e);
102 			}
103 			else
104 			{
105 			    try
106 			    {
107 				jEditorPane1.setPage(e.getURL());
108 			    }
109 			    catch (java.io.IOException ioe)
110 			    {
111 				JOptionPane.showMessageDialog(null,ioe.getMessage(),(String)cc.rb.getObject("errors_messageboxheader"),JOptionPane.ERROR_MESSAGE);
112 			    }
113 			}
114 		    }
115 		}
116 	    };
117     }
118 }
119 
120 
121