xref: /titanic_41/usr/src/cmd/krb5/kadmin/gui/util/ContextHelp.java (revision bafec74292ca6805e5acb387856f4e60a5314b37)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * ident	"%Z%%M%	%I%	%E% SMI"
24  *
25  * Copyright (c) 1999-2000 by Sun Microsystems, Inc.
26  * All rights reserved.
27  */
28 
29 import java.awt.event.*;
30 import java.awt.*;
31 import java.util.ResourceBundle;
32 import java.util.MissingResourceException;
33 
34 /**
35  * Dialog box for displaying context sensitive help.
36  * It is shared amongst the different frames when some frame is
37  * already in context help mode. When all the frames return to
38  * normal mode by dismissing the dialog box, this object is
39  * destroyed.
40  */
41 // The approach of simply hiding the context dialog box till the next
42 // time it is needed will not work too well. The problem arises
43 // because the dialog box is associated with a parent frame. Whenever
44 // the dialog box goes from invisible to visible this parent frame
45 // also pops to the top. This might be a little counter-intuitive to a
46 // user when he/she asks for help on frame A and has frame B popping
47 // up for no apparent reason.
48 public class ContextHelp extends HelpDialog {
49 
50     private KdcGui kdcGui;
51 
52     private static Cursor c = new Cursor(Cursor.DEFAULT_CURSOR);
53 
54     // For I18N
55     private static ResourceBundle rb =
56     ResourceBundle.getBundle("GuiResource" /* NOI18N */);
57 
58     public ContextHelp(Frame parent, KdcGui kdcGui) {
59         super(parent, getString("Context-Sensitive Help"), false);
60         this.kdcGui = kdcGui;
61         setText(getString(
62         "Click on GUI items to get help.\n\nClick on button below to dismiss"));
63     }
64 
65     /**
66      * Call rb.getString(), but catch exception and return English
67      * key so that small spelling errors don't cripple the GUI
68      *
69      */
70     private static final String getString(String key) {
71         try {
72   	    String res = rb.getString(key);
73 	    return res;
74         } catch (MissingResourceException e) {
75 	    System.out.println("Missing resource "+key+", using English.");
76 	    return key;
77         }
78     }
79 
80     protected void quit() {
81         if (kdcGui.loginHelpMode) {
82             kdcGui.setupLoginNormalListeners();
83             kdcGui.realLoginFrame.setCursor(c);
84         }
85 
86         if (kdcGui.mainHelpMode) {
87             kdcGui.setupMainNormalListeners();
88             kdcGui.realMainFrame.setCursor(c);
89         }
90 
91         if (kdcGui.defaultsHelpMode) {
92             kdcGui.setupDefaultsNormalListeners();
93             kdcGui.defaultsEditingFrame.setCursor(c);
94         }
95 
96         // Set the reference to this to null to indicate to kdcGui that it
97         // has to create a new ContextHelp object the next time one is
98         // needed
99         kdcGui.cHelp = null;
100 
101         super.quit();
102     }
103 
104 }
105