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