xref: /illumos-gate/usr/src/lib/libslp/javalib/com/sun/slp/SLPDgui.java (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
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 by Sun Microsystems, Inc.
26  * All rights reserved.
27  *
28  */
29 
30 //  SCCS Status:      %W%	%G%
31 //  %M : The service location daemon GUI.
32 //  Author:           Erik Guttman
33 //
34 
35 package com.sun.slp;
36 
37 /**
38  * This GUI will allow the user of the slpd to monitor the daemon,
39  * shut it off, manually enter services and stuff like that.
40  *
41  * @version %R%.%L% %D%
42  * @author Erik Guttman
43  */
44 
45 import java.awt.*;
46 import java.util.*;
47 
48 class SLPDgui extends Frame {
49     public SLPDgui(String configFile) {
50 
51         super("slpd");
52 
53 	Font font = new Font("SansSerif", Font.BOLD, 12);
54 
55 	setFont(font);
56 
57 	configFilename = configFile;
58 
59 	setLayout(new BorderLayout());
60 
61 	// Set up a panel displaying config file.
62 	Panel configPanel = new Panel();
63 	configPanel.setLayout(new FlowLayout());
64 
65 	configPanel.add(new Label("Configuration file:", Label.CENTER));
66 	configPanel.add(new Label(configFile == null ? "":configFile));
67 	add("North", configPanel);
68 
69 	taLog = new TextArea();
70 	taLog.setEditable(false);
71 	add("Center", taLog);
72 
73 	Panel pS = new Panel();
74 	pS.setLayout(new FlowLayout());
75 	pS.add(new Button("Quit"));
76 
77 	add("South", pS);
78 
79 	// Use JDK 1.1 event model in compatibility mode w. 1.0.
80 
81 	enableEvents(AWTEvent.WINDOW_EVENT_MASK);
82 
83 	setSize(WIDTH, HEIGHT);
84     }
85 
86     public void processEvent(AWTEvent evt) {
87 	if (evt.getID() == Event.WINDOW_DESTROY) {
88 	  try {
89 	    slpd.stop();
90 
91 	  } catch (ServiceLocationException ex) {
92 	    SLPConfig conf = SLPConfig.getSLPConfig();
93 	    ResourceBundle bundle = conf.getMessageBundle(conf.getLocale());
94 
95 	    slpd.errorExit(bundle, ex);
96 
97 	  }
98 	}
99 
100 	super.processEvent(evt);
101     }
102 
103     TextArea getTALog() {
104 
105 	return taLog;
106 
107     }
108 
109     // Size of main window.
110 
111     static private int WIDTH = 780;
112     static private int HEIGHT = 750;
113 
114     private String configFilename;
115     private TextArea taLog;
116 
117 }
118