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